无法使用bean:在jsp页面中的非stuts标签中定义变量

时间:2013-01-23 10:57:38

标签: jsp jstl struts-1

我可以在scriptlet中使用“acctNum”作为<%= acctNum%>在下面代码中提到的标记内的语句块中。

<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>

但在</logic:greaterEqual>之后的任何地方,我都无法在代码中使用它 在scriptlet中使用它时,它给出了间歇性错误,即在<% --- %>内,我得到' acctNum无法解析'

但是如果我在任何struts标签中使用它,例如<bean:write name="acctNum">

,它就有效

如果有解决方法,请告诉我

1 个答案:

答案 0 :(得分:1)

我能够解决这个问题。

我发现所有stuts标签都可以获取值,但是如果我使用的是scriptlet / JSTL标签,那么我没有得到这些值,

为此我必须做一个解决方法,并在脚本的情况下像<%pageContext.getAttribute("acctNum") %>一样使用它 和 对于JSTL <c:out value="pageContext.acctNum">