The Tiles in Struts 2 does not support action?

Component/s: Plugin - Tiles
Affects Version/s: 2.1.2
Fix Version/s: 2.1.3
Environment:  WebSphere6.0.2 + JDK1.4 + Struts2.0.11.1
Flags: Important

Description
Hi,

My project is using tiles + Struts 2 to composite views, but the plug-in tiles(2.0.5) doesnt' support .action view any more as the following:

<definition name="xxx" template="/tiles/xxx/layout.jsp">
<put-attribute name="title"
value="xxx" />
<put-attribute name="header" value="/tiles/shas/header.jsp" />
********* <put-attribute name="toolbar" value="/navigate/navigateMenu.action" /> **********
<put-attribute name="body" />
<put-attribute name="copyright" value="/tiles/copyright.jsp" />
<put-attribute name="footer" value="/tiles/shas/footer.jsp" />
</definition>

But if I am not wrong, Struts1.X + Tiles1.X do support this function.

Many thanks

Richard

Quinet Jérémie added a comment - 08/Oct/08 03:06 AM

I recently add this problem and digging in it it has nothing to do with struts 2 nor tiles plugin, it's due to a servlet engine behavior.

The servlet engine doesn't invoke the filters on a forward/include on a RequestDispatcher, it was working in struts 1 because a servlet was in charge to manage the request and not a filter.

As i now there is no standard way to change this for a servlet 2.3 compliant engine, but for version 2.4 and subsequent it can be change, here is an extract from spec :

{quote}
New for version 2.4 of the Java Servlet specification is the ability to configure filters
to be invoked under request dispatcher forward() and include() calls.
By using the new <dispatcher> element in the deployment descriptor, the
developer can indicate for a filter-mapping whether he would like the filter to be
applied to requests when:
1. The request comes directly from the client.
This is indicated by a <dispatcher> element with value REQUEST,
or by the absence of any <dispatcher> elements.
2. The request is being processed under a request dispatcher representing the
Web component matching the <url-pattern> or <servlet-name> using a forward()
call.
This is indicated by a <dispatcher> element with value FORWARD.
3. The request is being processed under a request dispatcher representing the
Web component matching the <url-pattern> or <servlet-name> using an include()
call.
This is indicated by a <dispatcher> element with value INCLUDE.
4. The request is being processed with the error page mechanism specified in "Error
Handling" on page 73 to an error resource matching the <url-pattern>.
This is indicated by a <dispatcher> element with the value ERROR.
5. Or any combination of 1, 2, 3, or 4 above.{quote}

The tiles include on RequestDispatcher is now working for me with :

{code:xml}
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
{code}


如果给你带来帮助,欢迎微信或支付宝扫一扫,赞一下。