According to TLD or attribute directive in tag file, attribute value does not accept any expressions
显示这个异常是 因为在struts2的标签内部使用${}这样的方式,会出现。
.${}是EL语言的 %{}这样的形式是ognl表过式语言的,在struts2的标签内部,使用%{}这样的形式,在标签外部可以使用${}EL语言的方式
Struts 2从 version 2.0.11开始已经不支持struts tag与JSP EL表达式混合使用了(不在struts tag里使用EL还是可以的),而只支持OGNL
会导致一些恶意的ognl也被执行,所以不得不禁止掉了…
看来不得不去学习下ongl了。
也听说此ongl很强大。
Trick Tip:
对于<s:property>,是使用
<s:property value="#parameters.name " />
而对于<s:set>,则要使用(否则出错):
<s:set name="name" value="#parameters.name[0]" />
但是如果使用struts include tag来传参数,则<s:property>和<s:set>无法获取传来的参数,如:
<
body
>
<
s:include
value
= "/welcome.jsp"
>
<
s:param
name
="name"
>
Scott
</
s:param
>
</
s:include
>
</
body
>
那么在webcome.jsp 里通过<s:property>和<s:set>无法获取"name"参数:
<s:property value="#parameters.name " />
<s:set name="name" value="#parameters.name[0]" />
而只能够用
<%request.getParameter("name")%>
来获取
ONGL:http://www.blogjava.net/max/archive/2007/04/28/114417.html
1. 支持对象方法调用,如xxx.doSomeSpecial();
2. 支持类静态的方法调用和值访问,表达式的格式为@[类全名(包括包路径)]@[方法名 | 值名],例如:@java.lang.String@format('foo %s', 'bar')或@tutorial.MyConstant@APP_NAME;
3. 支持赋值操作和表达式串联,如price=100, discount=0.8, calculatePrice(),这个表达式会返回80;
4. 访问OGNL上下文(OGNL context)和ActionContext;
5. 操作集合对象。