如何在EL中评估scriptlet变量? [英] How to evaluate a scriptlet variable in EL?

查看:111
本文介绍了如何在EL中评估scriptlet变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否在<c:if>语句中使用了JSP.

I was wondering if there was anyway of using JSP in <c:if> statement.

例如

<c:if test="${ param.variable1 == 'Add' <% JSP variable clause %>}">

所以我也想检查我的JSP变量.

So I want my JSP variable to checked against as well.

有什么建议吗?我无知地试着仅仅坚持该子句,显然那是行不通的.

Any suggestions? I have tried ignorantly just sticking in the clause, obviously it did not work.

谢谢

推荐答案

所以您想在EL中评估 scriptlet 变量?将其存储为请求属性.

So you want to evaluate a scriptlet variable in EL? Store it as a request attribute.

<%
    String var = "some";
    request.setAttribute("var", var);
%>

<c:if test="${param.variable1 == 'Add' && var == 'some'}">

但是,这没有任何意义.您应该避免 脚本并使用JSTL/EL准备此变量.因此,如果您使功能要求更加明确,例如如何使用JSTL/EL做到这一点(插入 scriptlet 代码片段?"),那么我们将能够提出正确的方法.

However, this makes no sense. You should avoid scriptlets altogether and use JSTL/EL to prepare this variable. So if you make the functional requirement more clear, e.g. "How do I do this (insert scriptlet code snippet) using JSTL/EL?", then we'll be able to suggest the right approach.

例如,您可以使用<c:set>在EL作用域中设置变量.

For example, you could use <c:set> to set a variable in EL scope.

<c:set var="var" value="some" scope="request" />

另请参见:

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