问题描述
如下面的代码中所述,我能够在scriptlet内的语句块中将scriptlet中的"acctNum"用作<%= acctNum%>.
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>
但是我不能在</logic:greaterEqual>
之后的任何地方在代码中使用它在scriptlet中使用它时出现间歇性错误,即在<% --- %>
内部,我得到' acctNum无法解析'
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'
但是如果我在诸如<bean:write name="acctNum">
请让我知道是否可以解决此问题
Please let me know if there is a work around for this
推荐答案
我能够解决此问题.
我发现所有stuts标签都能很好地获取值,但是如果我使用scriptlet/JSTL标签,我就不会获取值,
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,
为此,我必须做一个变通办法,并在scriptlet的情况下像这样使用它<%pageContext.getAttribute("acctNum") %>
和用于JSTL <c:out value="pageContext.acctNum">
For that I had to do a workaround and use it like this <%pageContext.getAttribute("acctNum") %>
in case of a scriptletand for JSTL <c:out value="pageContext.acctNum">
这篇关于无法在jsp页面的非stuts标记中使用bean:define变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!