struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Lindholm <>
Subject Re: Getting Servlets and Struts 2.1.6 to work together?
Date Wed, 04 Mar 2009 18:32:05 GMT

Greg Lindholm wrote:
> Wes Wannemacher wrote:
>> On Tuesday 03 March 2009 14:31:36 Greg Lindholm wrote:
>>> Is this what you mean?
>>> 	<filter-mapping>
>>> 		<filter-name>struts2</filter-name>
>>> 		<url-pattern>*.action</url-pattern>
>>> 	</filter-mapping>
>>> I previously had it as <url-pattern>/*</url-pattern> based on all
>>> books
>>> and examples I was able to find. So is there no reason to include
>>> everything in the filter?
>> I would also map /struts/* 
>> I noticed today as well that struts was picking up an action I had
>> defined, 
>> even though I had no .action. I think I had seen it before
>> intermittently, but 
>> wasn't able to nail it down. Truthfully, I've been using conventions so
>> long 
>> that it strike me as odd at first. It was only because I was explicitly
>> trying 
>> to take it out of the equation for something I was working on that I
>> noticed. 
>> -Wes
>> -- 
>> Wes Wannemacher
>> Author - Struts 2 In Practice 
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> Why do you recommend mapping '/struts/*' to the struts filter? What uses
> this convention?
> Clearly there has been a change in behavior between 2.0.11  and 2.1.6, I'm
> wondering if this was intentional?  Does the FilterDispatcher now assume
> that ever request it sees must be an action? If so this kind of feels
> wrong for a Filter, I expect filters to handle what they need to and pass
> everything else through to the next layer.

I spent some time in the debugger and found out what 'really' changed was
the default action extensions (struts.action.extension) changed from just
'action' to 'action' plus "" (no extension).  This was causing my "/status"
request with no extension to be treated as an action.

The old (2.0.11) struts had:

The new (2.1.6) has:

If I explicitly set the extension back to just 'action' then It works like
it used to and the request goes thru to my servlet.

In my struts.xml I added: <constant name="struts.action.extension"
value="action" />

So I still have the question of what is the 'correct' filter mapping for the
struts filter? 

I found the FilterDispatcher javadocs which says:
"IMPORTANT: this filter must be mapped to all requests. Unless you know
exactly what you are doing, always map to this URL pattern: /* "

I also see that FilterDispatcher has been deprecated, a note in the upgrade
guide would have been nice :).  (I'm going to add what I've found to the
wiki so will include a note.)


View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message