views:

560

answers:

2

Hello,

I am trying to do something trivial and can't see what I'm missing. I have the following web.xml...

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

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

And when I use a URL like "http://localhost:8080/gallery.action", everything works just fine (because "gallery" is configured properly in struts.xml, etc, etc).

If, however, I hit "http://localhost:8080/gallery.do" instead - I get a 404 response. Tomcat does not appear to be forwarding the request to struts as there is no logging on struts side. Tomcat logs just show the 404.

I've tried changing the filter-mapping to *.blah and nothing works except for *.action. I don't see any conflicting information in the default web.xml file.

Anyone know what I'm missing?

A: 

That is because you do have a <servlet-mapping> for *.action, but no <servlet-mapping> for *.do

Salandur
I don't have a servlet mapping for *.action or *.do ... and I'm checking both web.xml and the servers default web.xml file.
Ben Benson
i see. looked over the [struts2] tag
Salandur
+1  A: 

Apparently Struts2 only recognizes the .action extension by default and one needs to configure other extensions as desired using struts.properties file:

struts.action.extension=action,do,etc

This was very misleading given that most documentation discusses how to forward to struts using filter-mapping exclusively.

Ben Benson