《struts2权威指南》学习笔记之struts2表单标签
来源:互联网 发布:sql注入攻击测试工具 编辑:程序博客网 时间:2024/05/02 02:35
几个辅助类:
package lee;
public class Book
...{
private String name;
private String author;
public Book()
...{
}
public Book(String name , String author)
...{
this.name = name;
this.author = author;
}
public void setName(String name)
...{
this.name = name;
}
public String getName()
...{
return this.name;
}
public void setAuthor(String author)
...{
this.author = author;
}
public String getAuthor()
...{
return this.author;
}
}
public class Book
...{
private String name;
private String author;
public Book()
...{
}
public Book(String name , String author)
...{
this.name = name;
this.author = author;
}
public void setName(String name)
...{
this.name = name;
}
public String getName()
...{
return this.name;
}
public void setAuthor(String author)
...{
this.author = author;
}
public String getAuthor()
...{
return this.author;
}
}
package lee;
public class BookService
...{
public Book[] getBooks()
...{
return new Book[]
...{
new Book("Spring2.0宝典","张三"),
new Book("轻量级J2EE企业应用实战","李四"),
new Book("基于J2EE的Ajax宝典","王五")
};
}
}
public class BookService
...{
public Book[] getBooks()
...{
return new Book[]
...{
new Book("Spring2.0宝典","张三"),
new Book("轻量级J2EE企业应用实战","李四"),
new Book("基于J2EE的Ajax宝典","王五")
};
}
}
<%...@ page language="java" contentType="text/html; charset=GBK"%>
<%...@taglib prefix="s" uri="/struts-tags"%>
<html>
<head><s:head/>
<title>成功页面</title>
</head>
<body>
checkboxList标签:<br>
<s:form>
<!-- 使用简单集合来生成多个复选框 -->
<s:checkboxlist name="bookList" label="请选择你喜欢的技术" list="{'spring','hibernate','struts'}" labelposition="left">
</s:checkboxlist>
<!-- 使用简单Map对象来生成多个复选框 -->
<s:checkboxlist name="bookMap" label="请选择你喜欢的出版日期" list="#{'spring':'2006','hibernate':'2007','struts':'2008'}" labelposition="left"
listKey="key" listValue="value">
</s:checkboxlist>
<!-- 使用集合里放多个JavaBean实例来生成多个复选框 -->
<s:bean name="lee.BookService" id="bs"></s:bean>
<s:checkboxlist name="bookBean" label="请选择你喜欢的图书" list="#bs.books" labelposition="left"
listKey="author" listValue="name">
</s:checkboxlist>
</s:form>
<s:form>
combobox标签:combox标签中的下拉菜单和selcet不同,此仅为帮助输入而设计<br>
<s:combobox list="{'spring','hibernate','struts'}" size="100" maxlength="20" name="bookcombo" ></s:combobox>
</s:form>
<s:form theme="simple">
日期选择部件,指定toggleType属性,且指定value="today"<br>
<s:datetimepicker name="order.date" label="购买日期" toggleType="explode" value="today"/><hr>
日期选择部件,指定了format属性<br>
<s:datetimepicker name="order.date" label="购买日期" displayFormat="yyyy年MM月dd日"/><hr>
日期选择部件,指定了weekStartsOn属性<br>
<s:datetimepicker name="order.date" label="购买日期" displayFormat="yyyy年MM月dd日" weekStartsOn="1"/><hr>
时间选择部件<br>
<s:datetimepicker label="选择出发时间" type="time" /><hr>
</s:form>
<s:form action="x">
使用doubleselect,必须指定form的action属性
支持两项的doubleselect列表框
<s:doubleselect
label="请选择您喜欢的图书"
name="author" list="{'张三', '李四','王五'}"
doubleList="top == '张三' ? {'struts', 'spring' , 'hibernate'} : {'struts2','spring2.0','hibernate3.0'}"
doubleName="book"/>
支持多项的doubleselect列表框
<s:set name="bs" value="#{'张三':{'struts1', 'spring1' , 'hibernat1'},'李四':{'struts2', 'spring2' , 'hibernate2'},'王五':{'struts3', 'spring3' , 'hibernate3'}}"></s:set>
<s:doubleselect
label="请选择您喜欢的图书"
name="authora"
list="#bs.keySet()"
doubleList="#bs[top]"
doubleName="booka"/>
</s:form>
<s:form theme="simple">
optiontransferselect标签使用
doubleList指定第二个list的内容,list指定第一个list的内容
<s:optiontransferselect
doubleList="{'struts','spring','hibernate'}"
list="{'struts2','spring2','hibernate2'}"
doubleName="2book"
name="1book"
leftTitle="升级版"
rightTitle="普通版"
multiple="true"
doubleMultiple="true"
addToLeftLabel="向左移动"
addToRightLabel="向右移动"
selectAllLabel="全部选择"
addAllToRightLabel="全部向右移动"
addAllToLeftLabel="全部向左移动"
emptyOption="true"
headerKey="1key"
headerValue="版本1图书"
doubleHeaderKey="2key"
doubleHeaderValue="版本2图书"
doubleEmptyOption="true"></s:optiontransferselect>
</s:form>
<s:form theme="simple">
select标签:使用简单集合
<s:select list="{'struts','spring','hibernate'}" name="a" multiple="true"></s:select><br>
select标签:使用map集合
<s:select list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="b" multiple="true"
listKey="value" listValue="key"></s:select><br>
select标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:select list="#bs.books" name="c" listKey="name" listValue="author"></s:select>
</s:form>
<s:form theme="simple">
radio标签:使用简单集合
<s:radio list="{'struts','spring','hibernate'}" name="a"></s:radio><br>
radio标签:使用map集合
<s:radio list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="b"
listKey="value" listValue="key"></s:radio><br>
radio标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:radio list="#bs.books" name="c" listKey="name" listValue="author"></s:radio>
</s:form>
<s:form theme="simple">
optgroup标签,用于和select标签组合
<s:select list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="a" listKey="value" listValue="key">
<s:optgroup label="Rob"
list="#{'jialiu':'ibatis','songqi':'xml'}"
listKey="value"
listValue="key"></s:optgroup>
<s:optgroup label="Ror"
list="#{'liuwi':'freemarker','ren1':'velocity'}"
listKey="value"
listValue="key"></s:optgroup>
</s:select>
</s:form>
<s:form theme="simple">
updownselect标签:使用简单集合对象生成可上下移动选项的列表框
<s:updownselect name="ac" list="{'struts','spring','hibernate'}"></s:updownselect><br>
updownselect标签:使用map集合对象生成可上下移动选项的列表框
<s:updownselect list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="bc" moveDownLabel="向下移动" moveUpLabel="向上移动"
listKey="value" listValue="key" emptyOption="true"></s:updownselect><br>
updownselect标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:updownselect list="#bs.books" name="cc" selectAllLabel="全部选择" multiple="true"
listKey="name" listValue="author" moveDownLabel="向下移动" moveUpLabel="向上移动"></s:updownselect>
</s:form>
</body>
</html>
<%...@taglib prefix="s" uri="/struts-tags"%>
<html>
<head><s:head/>
<title>成功页面</title>
</head>
<body>
checkboxList标签:<br>
<s:form>
<!-- 使用简单集合来生成多个复选框 -->
<s:checkboxlist name="bookList" label="请选择你喜欢的技术" list="{'spring','hibernate','struts'}" labelposition="left">
</s:checkboxlist>
<!-- 使用简单Map对象来生成多个复选框 -->
<s:checkboxlist name="bookMap" label="请选择你喜欢的出版日期" list="#{'spring':'2006','hibernate':'2007','struts':'2008'}" labelposition="left"
listKey="key" listValue="value">
</s:checkboxlist>
<!-- 使用集合里放多个JavaBean实例来生成多个复选框 -->
<s:bean name="lee.BookService" id="bs"></s:bean>
<s:checkboxlist name="bookBean" label="请选择你喜欢的图书" list="#bs.books" labelposition="left"
listKey="author" listValue="name">
</s:checkboxlist>
</s:form>
<s:form>
combobox标签:combox标签中的下拉菜单和selcet不同,此仅为帮助输入而设计<br>
<s:combobox list="{'spring','hibernate','struts'}" size="100" maxlength="20" name="bookcombo" ></s:combobox>
</s:form>
<s:form theme="simple">
日期选择部件,指定toggleType属性,且指定value="today"<br>
<s:datetimepicker name="order.date" label="购买日期" toggleType="explode" value="today"/><hr>
日期选择部件,指定了format属性<br>
<s:datetimepicker name="order.date" label="购买日期" displayFormat="yyyy年MM月dd日"/><hr>
日期选择部件,指定了weekStartsOn属性<br>
<s:datetimepicker name="order.date" label="购买日期" displayFormat="yyyy年MM月dd日" weekStartsOn="1"/><hr>
时间选择部件<br>
<s:datetimepicker label="选择出发时间" type="time" /><hr>
</s:form>
<s:form action="x">
使用doubleselect,必须指定form的action属性
支持两项的doubleselect列表框
<s:doubleselect
label="请选择您喜欢的图书"
name="author" list="{'张三', '李四','王五'}"
doubleList="top == '张三' ? {'struts', 'spring' , 'hibernate'} : {'struts2','spring2.0','hibernate3.0'}"
doubleName="book"/>
支持多项的doubleselect列表框
<s:set name="bs" value="#{'张三':{'struts1', 'spring1' , 'hibernat1'},'李四':{'struts2', 'spring2' , 'hibernate2'},'王五':{'struts3', 'spring3' , 'hibernate3'}}"></s:set>
<s:doubleselect
label="请选择您喜欢的图书"
name="authora"
list="#bs.keySet()"
doubleList="#bs[top]"
doubleName="booka"/>
</s:form>
<s:form theme="simple">
optiontransferselect标签使用
doubleList指定第二个list的内容,list指定第一个list的内容
<s:optiontransferselect
doubleList="{'struts','spring','hibernate'}"
list="{'struts2','spring2','hibernate2'}"
doubleName="2book"
name="1book"
leftTitle="升级版"
rightTitle="普通版"
multiple="true"
doubleMultiple="true"
addToLeftLabel="向左移动"
addToRightLabel="向右移动"
selectAllLabel="全部选择"
addAllToRightLabel="全部向右移动"
addAllToLeftLabel="全部向左移动"
emptyOption="true"
headerKey="1key"
headerValue="版本1图书"
doubleHeaderKey="2key"
doubleHeaderValue="版本2图书"
doubleEmptyOption="true"></s:optiontransferselect>
</s:form>
<s:form theme="simple">
select标签:使用简单集合
<s:select list="{'struts','spring','hibernate'}" name="a" multiple="true"></s:select><br>
select标签:使用map集合
<s:select list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="b" multiple="true"
listKey="value" listValue="key"></s:select><br>
select标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:select list="#bs.books" name="c" listKey="name" listValue="author"></s:select>
</s:form>
<s:form theme="simple">
radio标签:使用简单集合
<s:radio list="{'struts','spring','hibernate'}" name="a"></s:radio><br>
radio标签:使用map集合
<s:radio list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="b"
listKey="value" listValue="key"></s:radio><br>
radio标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:radio list="#bs.books" name="c" listKey="name" listValue="author"></s:radio>
</s:form>
<s:form theme="simple">
optgroup标签,用于和select标签组合
<s:select list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="a" listKey="value" listValue="key">
<s:optgroup label="Rob"
list="#{'jialiu':'ibatis','songqi':'xml'}"
listKey="value"
listValue="key"></s:optgroup>
<s:optgroup label="Ror"
list="#{'liuwi':'freemarker','ren1':'velocity'}"
listKey="value"
listValue="key"></s:optgroup>
</s:select>
</s:form>
<s:form theme="simple">
updownselect标签:使用简单集合对象生成可上下移动选项的列表框
<s:updownselect name="ac" list="{'struts','spring','hibernate'}"></s:updownselect><br>
updownselect标签:使用map集合对象生成可上下移动选项的列表框
<s:updownselect list="#{'zhangsan':'struts','lisi':'spring','wangwu':'hibernate'}"
name="bc" moveDownLabel="向下移动" moveUpLabel="向上移动"
listKey="value" listValue="key" emptyOption="true"></s:updownselect><br>
updownselect标签:使用集合里放多个javabean实例来生成下拉选择框
<s:bean name="lee.BookService" id="bs"/>
<s:updownselect list="#bs.books" name="cc" selectAllLabel="全部选择" multiple="true"
listKey="name" listValue="author" moveDownLabel="向下移动" moveUpLabel="向上移动"></s:updownselect>
</s:form>
</body>
</html>
- 《struts2权威指南》学习笔记之struts2表单标签
- 《struts2权威指南》学习笔记之struts2 ajax动态表单
- 《struts2权威指南》学习笔记之struts2 ajax标签
- 《struts2权威指南》学习笔记之struts2之Tree标签改进
- 《struts2权威指南》学习笔记之struts2 ajax标签之autocompleter
- 《struts2权威指南》学习笔记之struts2 ajax标签之tabbedPanel
- 《struts2权威指南》学习笔记之struts2 ajax标签s和submit
- 《struts2权威指南》学习笔记之在Freemarker中使用struts2标签
- 《struts2权威指南》学习笔记之struts2之文件下载
- 《struts2权威指南》学习笔记之struts2文件上传
- 《struts2权威指南》学习笔记之struts2文件上传
- 《struts2权威指南》学习笔记之struts2 pub-sub模型
- 《struts2权威指南》学习笔记之struts2整合Spring
- 《struts2权威指南》学习笔记之struts2整合jsf
- 《struts2权威指南》学习笔记之struts2文件上传--使用fileUpload拦截器
- 《struts2权威指南》学习笔记之struts2多文件上传--使用数组方式
- 《struts2权威指南》学习笔记之struts2+jsf+spring+sitemesh集成开发
- Struts2 form表单常用标签学习笔记
- 如何对Windows 2000中出现的“Stop 0x0000007B”错误信息进行故障诊断
- 如何解决网络连接问题
- httpRuntime 问题
- phpMyAdmin连接多服务器设置
- 如何将Windows 2000域控制器升级到Windows Server 2003
- 《struts2权威指南》学习笔记之struts2表单标签
- oracle维护常用sql语句
- 好几天没来了
- 基于Windows 2000 Server的域控制器上的Lsass.exe进程的内存使用量
- 有关Windows 2000 DNS的常见问题
- 如何使用ADSI和WSH脚本查找域中FSMO角色持有者
- smtp协议命令发信
- 将Windows 2000 DNS集成到现有的BIND或基于Windows NT 4.0的DNS命名空间中
- 如何查找FSMO角色担任者(服务器)