You need to change your filter-mapping in web.xml so that static
resources like images, css, js etc do not get processed by the struts
filter.

This is what I use where all actions use the *.action extension.

  <filter>
    <filter-name>struts2</filter-name>
    
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/struts/*</url-pattern>
  </filter-mapping>

If you don't want to use an extension you can use a prefix that
matches your namespace and you can have multiple filter-mapping
definitions one for each namespace.


  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/xxx/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/yyy/*</url-pattern>
  </filter-mapping>

The drawback with this is it doesn't work for the root (/) namespace
and since filter-mapping does not support any exclude pattern you
can't just exclude the images etc.

You may be able to modify the struts filter to exclude certain
patterns, assuming it doesn't already have this feature it sounds like
a nice enhancement.


On Thu, Jun 3, 2010 at 5:16 PM, Phil Davis <texasp...@gmail.com> wrote:
> Bummer,
>
> Even with two namespaces, "/" and "/images" it still wants to run the image
> file, "/images/logo.gif", as an action under the "/images" namespace, it
> complains that there is no action mapped....
>
> I also tried a single namespace for "/" and got the same error.
>
> So, I think this is a bug... one that probably will not occur very often,
> because I am not using struts in a "normal" way, but it does not provide the
> functionality that I need.  There should be a way to specify URLs and files
> that are NOT actions, at least when using a blank extension.
>
> I absolutely need blank extension... I hate extensions!  and no one will
> know what extension to goto to start the page.... the default page should be
> www.example.com, which is usually a static page, but I don't want a static
> page... I want to use some type of action.  Sure I could do a redirect....
> yuck!
>
> One more thing to try.... separate projects....
>
> OK, when I create a separate project "/images" and change the URL in the JSP
> file to the absolute path "/images/logo.gif" ... it works!  This is a
> separate project, not a namespace or anything within the defined project!!!!
>
> This is a HACK, but I can live with it for now!
>
> I still think it is a bug that empty extensions cause regular files to cease
> to work.
>
> Phil
>

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

Reply via email to