not able to use bean:define variable in non stuts tags in a jsp page

风流意气都作罢 提交于 2019-12-11 04:43:51

问题


I am able to use "acctNum" inside scriptlet as <%=acctNum %> with in the block of statements inside tag as mentioned in the below code.

<logic:greaterEqual name="childArraySize" value="1">
 <bean:define id="acctNum" name="overviewSel" property="accountNumber" type="String"/>
 <logic:equal name="accountNumber" value="<%=acctNum %>">
    <bean:define id="STItemIndex" name="ItemIndex"/>
    <bean:define id="overviewCh" name="overviewSel" type="com.beans.statements.StatementAccount"/>
    <bean:define id="arraySize"  name="childArraySize"/>
    <bean:define id="statementAccountTypeDesc" name="statementAccountTypeDescSel"/>
  </logic:equal>    
</logic:greaterEqual>

But I'm not able to use this in the code anywhere after </logic:greaterEqual> it gives me intermittent error when using it in a scriptlet i.e., inside <% --- %>, I am getting 'acctNum can not be resolved'

But it works if I use it in any struts tag like <bean:write name="acctNum">

Please let me know if there is a work around for this


回答1:


I was able to resolve this issue.

I found that all stuts tags are fine with getting the values, but if I'm using scriptlet/ JSTL tags I was not getting the values,

For that I had to do a workaround and use it like this <%pageContext.getAttribute("acctNum") %> in case of a scriptlet and for JSTL <c:out value="pageContext.acctNum">



来源:https://stackoverflow.com/questions/14478000/not-able-to-use-beandefine-variable-in-non-stuts-tags-in-a-jsp-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!