原因:struts2.1.X把struts2.0中的和ajax相关的,如datetimepicker,tree,treenode 都移动到了dojo中了
解决方法:
1、在jsp文件中加入<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>和<sx:head/>
2、将<s:datetimepicker label="XXXX" name="XXXX"></s:datetimepicker>改为<sx:datetimepicker label="XXXX" name="XXXX"></sx:datetimepicker>
3、将struts2-dojo-plugin-2.1.6.jar拷贝到/web-inf/lib下
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>
<head>
<title>编辑图书</title>
<s:head/>
<sx:head/>
</head>
<body>
<h2>
<s:if test="null == book">
增加图书
</s:if>
<s:else>
编辑图书
</s:else>
</h2>
<s:form name="editForm" action="save" validate="true">
<s:textfield label="书名" name="book.bookName"/>
<s:textfield label="作者" name="book.bookAuthor"/>
<s:textfield label="出版社" name="book.bookPublish"/>
<sx:datetimepicker label="出版日期" name="book.bookDate"></sx:datetimepicker>
<s:textfield label="ISBN" name="book.bookIsbn"/>
<s:textfield label="页数" name="book.bookPage"/>
<s:textfield label="价格(元)" name="book.bookPrice"/>
<s:textfield label="内容摘要" name="book.bookContent"/>
<s:if test="null == book">
<s:hidden name="book.bookId" value="%{bookId}"/>
</s:if>
<s:else>
<s:hidden name="book.bookId" />
</s:else>
<s:hidden name="queryName" />
<s:hidden name="queryValue" />
<s:submit value="%{getText('保存')}" />
</s:form>
<p><a href="<s:url action="list"/>">返回</a></p>
</body>
</html>
转载于:https://www.cnblogs.com/mingforyou/archive/2012/03/03/2378063.html