Posted on 2011-05-05 12:33
Kavin 閱讀(2379)
評論(0) 編輯 收藏
Title: Struts2里面
s:textfield標簽 Date類型的格式化
Description:.
JSP頁面里面有DatePickup,用Jquery綁定,但是Input框需要按指定格式輸出,默認是輸出11-5-5 (YY-M-D)
1 1 $(function() {
2 2
3 3 $("#datepickerstart").datepicker({
4 4
5 5 showOn: 'button',
6 6
7 7 buttonImage: '<%=path %>/images/calendar.gif',
8 8
9 9 buttonImageOnly: true
10 10
11 11 });
12 12
13 13 }
14 14
15 15 <s:textfield name="myDispatchmForm.planStartDate" id="datepickerstart">
Solution:
1.
<s:標簽不能嵌套,使用<s:param標簽指定輸出顯示的格式。
1 <s:textfield name="myDispatchmForm.planStartDate" id="datepickerstart">
2
3 <s:param name="value"><s:date name="myDispatchmForm.planStartDate" format="yyyy-MM-dd"/></s:param>
4
5 </s:textfield>
FORMAT屬性設定YYYY-MM-DD-hh-mm,年,月,日,小時,分.
把hh改成HH就是24小時制的,小寫就是12小時制的
2.
在html標簽里面套用struts2標簽.
1 <input type="text" value="<s:date name="person.birthday" format="yyyy-MM-dd" />" />