It took me some time to solve this, so I thought I'd share.  My immediate
need was to serve css, but static html, js, etc. could be done similarly.  

Also, I happen to have two namespaces in my struts2 app for security, which
isn't really important here, except that it demonstrates how to serve static
content with paths relative to two different roots.

--Config--
<struts>
 <package name="myapp" extends="struts-default" namespace = "">
   <!-- stuff removed -->

    <action name="*.css">
      <result>/css/{1}.css</result>
    </action>
 </package>
  
  <package name="myapp-admin" extends="struts-default" namespace="/admin">
    <!-- stuff removed -->

    <action name="*.css">
      <result>/css/admin/{1}.css</result>
    </action>
  </package>
</struts>

--Uses--
<!-- note how the paths are relative to two different roots -->

<!-- from an action/jsp in the myapp package -->
<link rel="stylesheet" type="text/css" href="myapp.css" />

<!-- from an action/jsp in the admin package -->
<link rel="stylesheet" type="text/css" href="admin.css" />

-- 
View this message in context: 
http://www.nabble.com/Struts2-static-content-tp19784601p24156484.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to