请教 struts 中的使用方法和优秀代码

dytsoft 2003-09-12 02:20:10
如题
...全文
584 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxl19790710 2003-09-27
  • 打赏
  • 举报
回复
可以看一下struts代的例子中的struts-exercise-taglib.war
filixlu 2003-09-27
  • 打赏
  • 举报
回复
1、jsp中代码
<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、form

public 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>
//以上就是我的代码的主要部分,
squallzeng 2003-09-24
  • 打赏
  • 举报
回复
O也在找有关于楼主想的的那种啊,一直没有结果,楼主如果知道了,麻烦给一份*-*
mail:squallzeng@hotmail.com
willyzeng 2003-09-24
  • 打赏
  • 举报
回复
有没有多个级连菜单的好的解决方案?
filixlu 2003-09-24
  • 打赏
  • 举报
回复
up
梦幻圣者 2003-09-12
  • 打赏
  • 举报
回复
在JB的安装目录下的extras\jakarta-struts-1.0.2-src\web\exercise-taglib有好多例子,你可以参考!
梦幻圣者 2003-09-12
  • 打赏
  • 举报
回复
<%@ page language="java" import="java.util.*, org.apache.struts.webapp.exercise.*;"%>
<%@ 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>
liuzhj 2003-09-12
  • 打赏
  • 举报
回复
<html:select property="fieldName">
<html:options name="stringValueArray"
labelName="stringDisplayArray"/>
</html:select>
hch_d 2003-09-12
  • 打赏
  • 举报
回复
whyxx 2003-09-12
  • 打赏
  • 举报
回复
去下一个新的struts,里面有个struts-exercise-taglib.war是官方提供的各种taglib的使用方法,

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧