字面上导致 StackOverflowError - Tiles 3

问题描述 投票:0回答:0

从 Struts 1.3/Tiles 1.x 组合迁移到 Struts 2/Tiles 3。 但这确实是一个 Tiles 问题

以前支持定义中的 bean 声明以支持作为菜单项的功能,Tiles 3 显然已经取消了。所以我转换了这个:

    <definition name=".selectPatient.menu" path="/WEB-INF/templates/menu.jsp">
        <putList name="items">
            <bean classtype="org.a.m.s.jsp.MenuItem">
                <set-property property="id" value="menubar_register"/>        
                <set-property property="name" value="menubar_register"/>        
                <set-property property="title" value="Register"/>        
                <set-property property="onclick" value="registerPatient()"/>        
                <set-property property="text" value="Register"/>
                <set-property property="roles" value="BASIC,LEAD,SUPER"/>        
            </bean>
            <bean classtype="org.a.m.s.jsp.MenuItem">
                <set-property property="id" value="menubar_multitransaction"/>        
                <set-property property="name" value="menubar_multitransaction"/>        
                <set-property property="title" value="Post Multiple Transactions"/>        
                <set-property property="onclick" value="postMultiTransactions()"/>        
                <set-property property="text" value="Post Multiple Transactions"/>
                <set-property property="roles" value="BASIC,LEAD,SUPER"/>
            </bean>
        </putList>
    </definition> 

以及对应的menu.jsp页面:

` <%if (UserRoles.userHasRole(request,item.getRoles())){%>

" cellpadding="0" cellspacing="0" border="0"> “ id="" accesskey="M" title="" class="menuItem" href="#" isDisabled="false" onclick="if (this.isDisabled != 'true'&&isPageReady()) ;" onmouseover="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_').style.backgroundColor='#ffff99';" onmouseout="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_').style.backgroundColor='#000066';"> `

定义:

    <definition name="defaultMenuComponent" template="/WEB-INF/templates/barbutton.jsp">
    </definition>

    <definition name="menubar_register" extends="defaultMenuComponent">
      <put-attribute name="id" value="menubar_register" cascade="true"/>
      <put-attribute name="name" value="menubar_register" cascade="true"/>
      <put-attribute name="title" value="Register" cascade="true"/>
      <put-attribute name="onclick" value="registerPatient()" cascade="true"/> 
      <put-attribute name="text" value="Register" cascade="true"/>
      <put-attribute name="roles" value="BASIC,LEAD,SUPER" cascade="true"/>   
    </definition>
    
    <definition name="menubar_multitransaction" extends="defaultMenuComponent">
      <put-attribute name="id" value="menubar_multitransaction" cascade="true"/>
      <put-attribute name="name" value="menubar_multitransaction" cascade="true"/>
      <put-attribute name="title" value="Post Multiple Transactions" cascade="true"/>
      <put-attribute name="onclick" value="postMultiTransactions()" cascade="true"/> 
      <put-attribute name="text" value="Post Multiple Transactions" cascade="true"/>
      <put-attribute name="roles" value="BASIC,LEAD,SUPER" cascade="true"/>   
    </definition>
    
    <definition name=".selectPatient.menu" template="/WEB-INF/templates/menu.jsp">
        <put-list-attribute name="items">
           <add-attribute value="menubar_register" type="definition"/>
           <add-attribute value="menubar_multitransaction" type="definition"/>   
        </put-list-attribute>
    </definition>

然后将所有构造逻辑推送到 barbutton.jsp 中:

<table id="button_<tiles:insertAttribute name="id" flush="true"/>" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="images/menu_button_round_edge_left2.gif"></td>
<td style="border-top:1px white solid; border-bottom:1px white solid;">
<a name="<tiles:insertAttribute name="name" flush="true"/>" id="<tiles:insertAttribute name="id" flush="true"/>" accesskey="M" title="<tiles:insertAttribute name="title" flush="true"/>" class="menuItem" href="#" isDisabled="false" onclick="if (this.isDisabled != 'true'&&isPageReady()) <tiles:insertAttribute name="onclick" flush="true"/>;" onmouseover="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<tiles:insertAttribute name="id" flush="true"/>').style.backgroundColor='#ffff99';" onmouseout="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<tiles:insertAttribute name="id" flush="true"/>').style.backgroundColor='#000066';"><tiles:insertAttribute name="text" flush="true"/>
</a>
</td>
<td><img src="images/menu_button_round_edge_right2.gif" width="9" height="17"></td>
</tr>
</table>

menu.jsp 更改如下:

<tilesx:useAttribute id="items" name="items" classname="java.util.List"/>

  <table border=0 cellpadding=0 cellspacing=1>
  <tr>       
     <c:forEach items="${items}" var="listItem">
       <td> 
       <tiles:insertDefinition name="${listItem}" flush="true"/> 
       </td>
     </c:forEach>
  </tr>
  </table>

它不起作用,获取 java.lang.StackOverflowError

尝试各种不同的方式

struts2 el tiles valuestack
© www.soinside.com 2019 - 2024. All rights reserved.