日历控件datetimepicker月份乱码
我用的是Struts2.1.8版本的dojo,所以用的是如下方法:
相比较struts2.0中,struts2.1.6 把struts2.0中的和ajax相关的,如datetimepicker,tree,treenode 都移动到了dojo中了,因此要使用datetimepicker标签要下一个struts2-dojo-plugin-2.1.6.jar包。
步骤:
1.struts2-dojo-plugin-2.1.6.jar引入到自己的项目中。
2.jsp中的开头加入如下内容
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/ struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
3. <head>中加入下列
<head>
<s:head theme="xhtml"/>
<sx:head parseContent="true"/>
</head>
4.页面中使用
<sx:datetimepicker name="birthday" value="%{date}" displayFormat="yy-MM-dd" />
9到12月份的乱码问题解决方法:
<sx:head parseContent="true" extraLocales="UTF-8"/>
<sx:datetimepicker name="birthday" value="%{date}" displayFormat="yy-MM-dd" language="UTF-8" />
源码:
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
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%>">
<s:head theme="xhtml"/>
<sx:head parseContent="true" extraLocales="UTF-8"/>
<title>My JSP 'index.jsp' starting page</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>
<s:form action="birthday">
<sx:datetimepicker name="birthday" value="%{date}" displayFormat="yy-MM-dd" language="UTF-8" />
<s:submit/>
</s:form>
</body>
</html>
2.1.6版本的解决方法:http://download.csdn.net/source/1735882