struts2 标签库 /struts-dojo-tags not found&Expression parameters.parseContent is undefined
问题一:/struts-dojo-tags" not found
问题二:Expression parameters.parseContent is undefined on line 45, column 28 in template/ajax/head.ftl.
myeclipse新建web project,添加struts2特性之后,会有如下图的类库出现:
其中并没有包含struts2-dojo-plugin类库。搜索struts2-dojo-plugin-2.1.2.jar并下载,添加到项目类库文件中,
然后再在/Struts2***Test/WebRoot/WEB-INF/lib下添加类库:
最后在jsp中,加入
<%@ taglib uri="/struts-dojo-tags" prefix="sx" %>
可以成功解决问题一错误。
插曲:测试过程中有个时间段,项目中的任何一个jsp文件都无法通过URL访问,检查所有的文件、类库、配置和tomcat
都没有问题。新建一个jsp页,同样也是无法打开。最后通过Project/clean的方法之后,成功解决。还没找到原因。
下面两步会出现问题二所示的错误。
1.加入ajax theme
<s:head theme="ajax"/>
2.使用典型的struts2标签dateTimePicker
<sx:datetimepicker name="date" label="please choose date"></sx:datetimepicker>
错误分析:
参考地址:http://blog.csdn.net/zhangyulin54321/article/details/9109139
原因:struts2.0到struts2.1有一个重要的改变就是对ajax支持的改变,struts2.0的ajax支持主要以DWR和dojo为主,并专门提供ajax主题,如:<s:head theme="ajax"/>,但是在struts2.1不在提供ajax主题,而将原来的ajax主题放入了dojo插件中,我们需要将dojo标签引入到jsp页面。
解决方法:<head></head>标签中对theme的引用方式必须改变,如下:
<s:head theme="xhtml"/>
<sx:head parseContent="true"/>
之后就能够正确的使用struts2的表单UI标签了。
截图如下: