去下一个新的struts,里面有个struts-exercise-taglib.war是官方提供的各种taglib的使用方法,
解决方案 »
- 为什么通过Action访问页面后,页面的CSS失效,而通过URL直接访问时可用
- java 中怎么样把数据库中的数据显示在TextArea中
- 为什么我在运行的时候(SSH)会说找不到action-servlet.xml
- hibernate 多表查询怎么将数据封装到不同Bean中?
- Hibernate 无主键多条件查询
- 请各位大侠帮帮忙,不知道是什么错照成的
- 弱弱的问个关于Javascript页面取得日期与系统日期比较的问题
- 求开发人员
- 何处可以下载Borland Appserver?
- springboot项目如何部署到windows tomcat里面
- 我想开发一个类csdn的论坛,有没有必要用到ejb。
- 实战EJB2。0(中文),不甘独享,请大家分享!
<html:options name="stringValueArray"
labelName="stringDisplayArray"/>
</html:select>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<head>
<title>Test html:select Tag</title>
<%
String multipleValues[] =
{ "Multiple 0", "Multiple 1", "Multiple 2", "Multiple 3", "Multiple 4",
"Multiple 5", "Multiple 6", "Multiple 7", "Multiple 8", "Multiple 9" };
pageContext.setAttribute("multipleValues", multipleValues); Vector options = new Vector();
options.add(new OptionBean("Label 0", "Value 0"));
options.add(new OptionBean("Label 1", "Value 1"));
options.add(new OptionBean("Label 2", "Value 2"));
options.add(new OptionBean("Label 3", "Value 3"));
options.add(new OptionBean("Label 4", "Value 4"));
options.add(new OptionBean("Label 5", "Value 5"));
options.add(new OptionBean("Label 6", "Value 6"));
options.add(new OptionBean("Label 7", "Value 7"));
options.add(new OptionBean("Label 8", "Value 8"));
options.add(new OptionBean("Label 9", "Value 9"));
pageContext.setAttribute("options", options);
%>
</head>
<body bgcolor="white"><div align="center">
<h1>Test struts-html Select Tag</h1>
</div>Whatever changes you make to properties should be reflected when the page
is redisplayed. Press "Save" to update, or "Cancel" to return to the
main menu.<html:form action="html-select.do">
<table border="0" width="100%"> <tr>
<th align="right">Single Select Allowed:</th>
<td align="left">
<html:select property="singleSelect" size="10">
<html:option value="Single 0">Single 0</html:option>
<html:option value="Single 1">Single 1</html:option>
<html:option value="Single 2">Single 2</html:option>
<html:option value="Single 3">Single 3</html:option>
<html:option value="Single 4">Single 4</html:option>
<html:option value="Single 5">Single 5</html:option>
<html:option value="Single 6">Single 6</html:option>
<html:option value="Single 7">Single 7</html:option>
<html:option value="Single 8">Single 8</html:option>
<html:option value="Single 9">Single 9</html:option>
</html:select>
</td>
</tr> <tr>
<th align="right">Multiple Select Allowed:</th>
<td align="left">
<html:select property="multipleSelect" size="10" multiple="true">
<html:options name="multipleValues" labelName="multipleValues"/>
</html:select>
</td>
</tr> <tr>
<th align="right">Multiple Select From A Collection:</th>
<td align="left">
<html:select property="collectionSelect" size="10" multiple="true">
<html:options collection="options" property="value" labelProperty="label"/>
</html:select>
</td>
</tr> <tr>
<td align="right">
<html:submit>Save</html:submit>
</td>
<td align="left">
<html:reset>Reset</html:reset>
<html:cancel>Cancel</html:cancel>
</td>
</tr></table></html:form>
</html:html>
mail:[email protected]
<bean:define id="theList" name="deviceTypeInfoForm" property = "deviceCategoryList" type = "java.util.ArrayList"/>
<html:select property="deviceCategory" onchange="submitForm(this.form)">
<option >请选择种类</option>
<html:options collection="theList" property="deviceCategory" labelProperty="deviceCategoryName"/>
</html:select>
2、formpublic class DeviceTypeInfoForm extends ActionForm {
//下面三个成员要有对应的getter和setter方法
private String deviceCategory;
private String deviceCategoryName;
private ArrayList deviceCategoryList;//deviceCategoryList里面保存的是DeviceTypeInfoForm 实例
//下面是塞实例的代码
public DeviceTypeInfoForm(String listName,String id ,String name){
if(listName.equals("Category")){
this.deviceCategory=id;
this.deviceCategoryName=name; }
//..................其它代码.......}
public DeviceTypeInfoForm(){
deviceCategoryList=new ArrayList();
deviceCategoryList.clear();
deviceCategoryList.add(new DeviceTypeInfoForm("Category","0","种类一"));
deviceCategoryList.add(new DeviceTypeInfoForm("Category","1","种类二"));
deviceCategoryList.add(new DeviceTypeInfoForm("Category","2","种类三"));
deviceCategoryList.add(new DeviceTypeInfoForm("Category","3","种类四")); //...................... }
}3、配置文件
<form-bean name="deviceTypeInfoForm" type="dms.form.baseinfo.device.DeviceTypeInfoForm" />
<action
path="/deviceTypeInfoAction"
input="/basic/deviceTypeInfoList.jsp"
name="deviceTypeInfoForm"
type="dms.action.baseinfo.device.DeviceTypeInfoAction"
validate="false">
<forward name="listAllOk" path="/basic/deviceTypeInfoList.jsp" />
<forward name="addjsp" path="/basic/deviceTypeInfo.jsp" />
</action>
//以上就是我的代码的主要部分,