Serving static content with Struts2: Tomcat error 404

Posted by Nicolas Raoul on Stack Overflow See other posts from Stack Overflow or by Nicolas Raoul
Published on 2010-06-02T09:07:49Z Indexed on 2010/06/02 9:13 UTC
Read the original article Hit count: 266

Filed under:
|
|
|

With Struts2 I can't find a way to serve a static CSS :-/ Newbie question but I could not find any answer on the Internet:

The CSS file is static/styles.css in my WAR file.

Tomcat replies with 404 when I request http://server/myapp/static/styles.css

But it works if I put styles.css at the root of the WAR and request http://server/myapp/styles.css

I tried adding the following to my struts.xml in the only package but still 404:

<action name="/static/*">
  <result>/static/{1}</result>
</action>

Or as a second package:

<package name="static" extends="struts-default" namespace="/static">
  <action name="/static/*">
    <result>/static/{1}</result>
  </action>
</package>

© Stack Overflow or respective owner

Related posts about tomcat

Related posts about static