3
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.

TomcatをJS/CSS静的コンテンツの扱い方法

Posted at

簡易の環境では、Nginxなどの代わりに、Tomcatから静的コンテンツを返却してほしいです。

Warファイルはwebapps/ROOTに展開されていて、JS/CSSはwebapps/ROOT/assets-dirに格納しています。

この場合server.xml設定ファイルを下記のように、Context要素を利用することができます。

<Host name="localhost"  appBase="webapps"
    unpackWARs="true" autoDeploy="true">

    <Context docBase="ROOT/assets-dir" path="/assets" />

</Host>

Tomcatを再起動すると、http://localhost/assets/some.cssがアクセスことができるようになるはずです。

3
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
3
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?