只是截取项目中部分代码,供参考及日后查阅
用struts1标签html:select展现select下拉列表
刚开始为如下代码:
<html:select name="ShuiwujiguanForm" property="swjg_dmSelect" >
<option value=""></option>
<html:options collection="select_list" property="swjg_dm" labelProperty="swjg_mc"/>
</html:select>
需要改为按树级分层的结构,如下图:代码修改为:<html:select name="ShuiwujiguanForm" property="swjg_dmSelect" >
<option value=""></option>
<logic:iterate id="select_list" name="ShuiwujiguanForm" property="select_list" scope="request">
<option value="<bean:write name="select_list" property="swjg_dm"/>">
<logic:equal name="select_list" property="swjg_level" value="1">nbsp;nbsp;</logic:equal>
<logic:equal name="select_list" property="swjg_level" value="2">nbsp;nbsp;nbsp;nbsp;</logic:equal>
<logic:equal name="select_list" property="swjg_level" value="3">nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;</logic:equal>
<logic:equal name="select_list" property="swjg_level" value="4">nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; </logic:equal>
<bean:write name="select_list" property="swjg_mc"/>
</option>
</logic:iterate>
</html:select>
nbsp;替换为 ,在这里 不显示
logic:equal 进行判断,级别为1的进行空格,为2的再多空格,依次类推。
logic:iterate用法
id 脚本变量的名称,它保存着集合中当前元素的句柄。
name 代表了你需要叠代的集合(不知道和property有啥区别),来自session或者request的属性。
type 是其中的集合类元素的类型
1、name和property都存在的时候有值
<logic:iterate id="select_list" name="ShuiwujiguanForm" property="select_list" scope="request">
</logic:iterate>
遍历的是property="select_list"的值
2、有property无name时报错
<logic:iterate id="select_list " property="select_list" scope="request">
</logic:iterate>
3、有name无property时有值<logic:iterate id=" select_list " name="select_list" scope="request">
</logic:iterate>
遍历的是 name="select_list"的值id保存着集合中当前元素,可随意取值 但iterator标签内的标签一些name属性就要引用这个id值
例如id取值为a:
<logic:iterate id="a" name="ShuiwujiguanForm" property="select_list" scope="request">
<option value="<bean:write name="a" property="swjg_dm"/>">
<logic:equal name="a" property="swjg_level" value="1">nbsp;nbsp;</logic:equal>
<bean:write name="a" property="swjg_mc"/>
</option>
</logic:iterate>
bean:write用法
bean:write常用的属性有如下几个:
1、name,用来指定属性的名字
2、filter,用来指定是否屏蔽到属性值的HTML格式
3、property,用来指定name所代表的对象的属性名字
4、format,用来指定显示的时间,数字,日期等的格式
只介绍name与property属性
例1
action中设置了request.setAttribute("hello","hello world");
则在jsp页面中,用struts的write标签取出并显示的方式如下:
<bean:write name="hello"/>,则页面上显示出hello world。
例2
假如有User类和Dept类,User类有属性名字userName,年龄age,和所属的Dept,
Dept类有属性组名deptName,并均具有相应的get和set方法。
某处设置了request.setAttribute("user",new User("张三","23","男",new Dept("开发部")));
则在某个jsp页面中,用struts的write标签取出并按指定方式显示结构体的方法如下:
用户名:<input type="text" value="<bean:write name="user" property="userName"/>">
年龄:<input type="text" value="<bean:write name="user" property="age"/>">
性别:<input type="text" value="<bean:write name="user" property="sex"/>">
组名:<input type="text" value="<bean:write name="user" property="dept.deptName"/>">
分享到:
相关推荐
我就是靠这个文档实现logic:iterate的循环的 struts 标签 logic:iterate使用 logic:iterate <br>第一页 是struts官方的说明, 第二页 是个例子 第三页 是我实现的arrayList放入标签的方法。 这是页面...
1. Map里存放的是bean时 <br><logic:iterate id="destMap" name="srcMap"> <br> <bean:define id="bean" name="destMap" property="value" /> <br> <bean:write name="bean" property="name" /> <br></...
struts标签库 文章目录 bean:cookie 2 bean:define 3 bean:header 4 bean:include 5 bean:message 5 bean:page 7 bean:parameter 7 bean:resource 8 bean:size 8 bean:struts 9 bean:write 9 html:base 10 ...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 ...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 ...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 ...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 ...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>...
16.3.4、<logic:iterate>标签 16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:...
<html:option value="pagetype" ><bean:write name="pagetype" /></html:option> document.forms[0].page.options[${page.currentPage}-1].selected = true; </c:forEach> ...
Struts+Spring+Hibernate实现上传下载 本文将围绕SSH文件上传下载的主题,向您详细讲述如何开发基于SSH的Web程序。SSH各框架的均为当前最新版本: •Struts 1.2 •Spring 1.2.5 •Hibernate 3.0 本文...