struts在Struts2中使用tile结果导致StackOverflowError-的Action标记

时间:2016-11-19 15:42:33

标签: java struts2 apache-tiles

我已将我的struts应用程序升级到版本2.3.30和apache-tiles 2.2.2并且我面临s:action标记和tile结果的问题。 它进入递归循环并抛出StackOverflowError,如下所示。

我也能在展示应用程序中重现这个问题,我已经概述了tiles.xml,struts-tile.xml和layout.jsp,如下所示。

it throws java.lang.StackOverflowError: null
    at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:230) 
        at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:230)
    at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:230)
    at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:230)
    .................. (truncated)
    .................
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    at org.apache.struts2.components.ActionComponent.executeAction(ActionComponent.java:288)
    at org.apache.struts2.components.ActionComponent.end(ActionComponent.java:172)
    at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
    at org.apache.jsp.WEB_002dINF.tiles.layout_jsp._jspx_meth_s_005faction_005f0(layout_jsp.java:210)
    at org.apache.jsp.WEB_002dINF.tiles.layout_jsp._jspService(layout_jsp.java:109)

这是我的用法,

tiles.xml

<definition name="showcase.index" template="/WEB-INF/tiles/layout.jsp">
    <put-attribute name="title" value="Tiles Showcase"/>
    <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
    <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/>
</definition>

<definition name="showcase.index.actionResult" template="/WEB-INF/tiles/actionTileResult.jsp">
    <put-attribute name="title" value="Tiles Result from action"/>
</definition>

支柱-tiles.xml

    <action name="index">
        <result type="tiles">showcase.index</result>
        <result name="success" type="tiles">showcase.index</result>
    </action>

    <action name="myTestAction">
        <result type="tiles">showcase.index.actionResult</result>
        <result name="success" type="tiles">showcase.index.actionResult</result>
    </action>

Layout.jsp

<html>
    <head><title>Struts2 Showcase - <tiles:getAsString name="title"/></title></head>
<body>
    <tiles:insertAttribute name="header"/>
    <tiles:insertAttribute name="body"/>
    <p>Notice that this is a layout made in JSP</p>
    <!-- This action causing stackoverflow error --> 
**  <s:action name="myTestAction" namespace="/tiles" executeResult="true" /> **
</body>
</html>

actionTileResult.jsp

<tiles:importAttribute name="title" scope="request"/>
<html>
    <head><title>Action tile result <tiles:getAsString name="title"/></title></head>
<body>
    <p>Notice that this is a  jsp</p>
</body>
</html>

请告诉我任何遇到类似问题的人及其任何解决方案。

0 个答案:

没有答案