无法在jsp页面的非stuts标记中使用bean:define变量 [英] not able to use bean:define variable in non stuts tags in a jsp page

查看:92
本文介绍了无法在jsp页面的非stuts标记中使用bean:define变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下面的代码中所述,我能够在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 scriptlet and for JSTL <c:out value="pageContext.acctNum">

这篇关于无法在jsp页面的非stuts标记中使用bean:define变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆