struts2豐富的標籤,把web開發變的很簡單,有個datetimepicker控件,對輸入日期時,很方便
<1>首先加入struts2-dojo-plugin-2.1.8.jar庫
<2>在頁面的頭部加上<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<3>然後在頁面的<head>下加入:<sx:head extraLocales="UTF-8"/> 這裏是加入UTF-8屬性,是爲了中文顯示
<4>然後就可以使用了;
Jsp代碼
<%@ page contentType="text/html; charset=gb2312" pageEncoding="gb2312"%>
- <%@taglib prefix="s" uri="/struts-tags"%>
- <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
- <html>
- <head>
- <title>註冊</title>
- <sx:head extraLocales="UTF-8"/>
- </head>
- <body>
- <s:form action="register" method="post">
- <s:textfield label="暱稱" name="userName" />
- <sx:datetimepicker language="UTF-8" label="出生日期" name="userBirthday" value="%{'1990-01-01'}" displayFormat="yyyy-MM-dd"/>
- </s:form>
- <input type="button" value="註冊" />
- </body>
- </html>
<span style="font-family:KaiTi_GB2312;font-size:18px;"><%@ page contentType="text/html; charset=gb2312" pageEncoding="gb2312"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
<title>註冊</title>
<sx:head extraLocales="UTF-8"/>
</head>
<body>
<s:form action="register" method="post">
<s:textfield label="暱稱" name="userName" />
<sx:datetimepicker language="UTF-8" label="出生日期" name="userBirthday" value="%{'1990-01-01'}" displayFormat="yyyy-MM-dd"/>
</s:form>
<input type="button" value="註冊" />
</body>
</html>
</span>
ok,詳細的就需要自己去研究了