Java Expression可在JSTL标签中使用,但不能在JSP页面的Struts 2标签中使用 [英] Java Expression works in JSTL tags but not in Struts 2 tags of a JSP page

查看:81
本文介绍了Java Expression可在JSTL标签中使用,但不能在JSP页面的Struts 2标签中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用"JSTL"和"struts2".我正在尝试使用JSTL和Struts2标记在范围内设置一个值,如下所示,

I am using "JSTL" ans "struts2" in my project.I am trying set a value in the scope using JSTL and Struts2 tag as follows,

<div id="id1"></div>
<div id="id2"></div>
<%               
   int b=10;
 %>
<c:set var="test2" value="<%= b %>"/>
<s:set var="test3" value=" <%=b%>" />
<script>
 document.getElementById("id1").innerHTML="${test2}"; //10
 document.getElementById("id2").innerHTML="${test3}"; //nothing is displayed.
</script>

输出仅为10.我的疑问是为什么表达式<%= b %><c:set>标记中起作用 不能在<s:set>标签中使用?

The output is 10 only. My doubt is why the expression <%= b %> works in <c:set> tag and not work in <s:set> tag?

推荐答案

Struts标记不允许在标记的属性中使用脚本.但是你可以尝试

Struts tags doesn't allow scriptlects in the tag's attributes. But you can try

<s:set var="test3"><%=b%></s:set>

这篇关于Java Expression可在JSTL标签中使用,但不能在JSP页面的Struts 2标签中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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