今天在学习Struts2标签中的datetimepicker出现这样一个exception:
No tag "datetimepicker" defined in tag library imported with prefix "s"
原因:struts2.3.8 把struts2中的和ajax相关的,如datetimepicker,tree,treenode都移动到了dojo中了
解决方法:
1.将struts2-dojo-plugin-2.3.8.jar拷贝到/web-inf/lib下
2.jsp页面文件加入"<%@taglib prefix="sx" uri="/struts-dojo-tags"%>"
3.在使用<s:datetimepicker>前添加<sx:head/>
4.<s:datetimepicker>换成<sx:datetimepicker>
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>datetimepicker用法</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<sx:head />
<s:form>
出生日期:
<sx:datetimepicker name="mydate" toggleType="explode"
value="today" type="date" language="zh_CN" />
</s:form>
</body>
</html>