最近在学习经典的SSH框架。在访问一个JSP时,抛出一个异常:
Expression parameters.pushId is undefined on line 24, column 6 in template/ajax/div-close.ftl.
想找异常的根源也是很难找,因为JSP转为Servlet之后你也看不到代码。
这当然不是因为自己的代码中遗漏了什么,而是因为Struts 2.1比Struts 2.0改进了一些东西。
之所以会抛出这个异常,是因为代码中有如下代码:
<span style="font-size:14px;"><%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="dojo"%>
...
<s:div theme="ajax" href="%{ news }" showLoadingText="false" updateFreq="3000" indicator="indicator" /></span>
这里不使用Struts的taglib,使用struts-dojo-tags的taglib就好,即改为:
<span style="font-size:14px;"><dojo:div theme="ajax" href="%{ news }" showLoadingText="false" updateFreq="3000" indicator="indicator" /></span>
这里把theme=“ajax”去掉也可以。可能是Struts 2.1把所有ajax请求的相关标签都改用dojo封装了吧,毕竟dojo才是专业的前端框架。