欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Struts日历选择框 标签详解

程序员文章站 2023-01-22 20:33:34
先导入struts2-dojo-plugin-2.1.6.jar,再在页面最开头加上:   <%@ taglib prefix="sx" uri="/s...
先导入struts2-dojo-plugin-2.1.6.jar,再在页面最开头加上:

 

<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

 

在<head> </head>中加入<sx:head />

 

下面的代码直接就实现了日历选择框:

 

[html]  

<sx:datetimepicker label="日历" name="calendar" value="today"   

toggletype="plain" toggleduration="300" language="zh_cn" type="date"   

displayweeks="5" displayformat="dd/mm/yyyy" formatlength="long"  />  

parameters:

 

Struts日历选择框 标签<sx:datetimepicker.../>详解

 

(注:toggle['tɒg(ə)l]触发)

 

最后的效果如下图:

 

 Struts日历选择框 标签<sx:datetimepicker.../>详解

 

value属性的写法还有:

 

<sx:datetimepicker value="%{date}"/>

 

<sx:datetimepicker value="%{'2007-01-01'}"/>

<sx:datetimepicker value="%{'today'}"/>

 

datetimepicker标签解析:

description:

renders a date/time picker in a dropdown(下拉) container.

 

a stand-alone datetimepicker widget(文本桌面) that makes it easy to select a date/time, or increment by week, month, and/or year.

 

it is possible to customize the user-visible formatting with either the 'formatlength' (long, short, medium or full) or 'displayformat' attributes. by defaulty current locale(区域设置) will be used.

 

参数displayformat的所有可能取值:

 

format description

d day of the month

d day of year

m month - use one or two for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name.

y year

h hour [1-12].

h hour [0-23].

m minute. use one or two for zero padding.

s second. use one or two for zero padding.

the following formats(in order) will be used to parse the values of the attributes 'value', 'startdate' and 'enddate':

 

simpledateformat built using rfc 3339 (yyyy-mm-dd't'hh:mm:ss)

simpledateformat.gettimeinstance(dateformat.short)

simpledateformat.getdateinstance(dateformat.short)

simpledateformat.getdateinstance(dateformat.medium)

simpledateformat.getdateinstance(dateformat.full)

simpledateformat.getdateinstance(dateformat.long)

simpledateformat built using the value of the 'displayformat' attribute(if any)