1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Conventionプラグイン利用時の<s:include>の違い

Posted at

<s:include>の概要

JSPのインクルードと同様、JSPから別のJSPや静的リソースを読み込みます。
ただしConventionプラグインを導入していると、サーブレットコンテナで管理するWebコンテンツ:WEB-INF以下の構成も、Conventionプラグインの設定に従います。

具体的には、JSPファイルは /WEB-INF/content 以下に配置します(Conventionプラグインの設定で変更可能です)
content以下は、ActionクラスのNamespace設定と同じになります。

インクルード先のURLの指定方法

パス設定は、/WEB-INF からのパス指定ないしは相対パスです。

ただしディレクトリ構成やNamespaceの構成が必ずしも一定ではないので、例えばとあるActionからは../../include/sample.jsp、もう一方は ../include/sample.jspと、不定になるので良くありません。
このため、次のように/WEB-INF/contentからのファイルパスと同じ設定します。

<s:include value="/WEB-INF/content/includes/sample.jsp"/>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?