Struts标签库doubleselect标签实战

一 实战1

1 JSP页面

<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>使用s:doubleselect生成级联下拉列表框</title>
    <s:head/>
</head>
<body>
<h3>使用s:doubleselect生成级联下拉列表框</h3>
<s:form action="x">
    <s:doubleselect
        label="请选择您喜欢的图书"
        name="author" list="{'李刚', 'David'}"
        doubleList="top == '李刚' ? {'轻量级Java EE企业应用实战',
        '疯狂iOS讲义','疯狂Java讲义'}:
        {'JavaScript: The Definitive Guide'}"
        doubleName="book"/>    
</s:form>
</body>
</html>

2 测试

Struts标签库doubleselect标签实战

二 实战2

1 JSP页面

<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>使用s:doubleselect生成级联下拉列表框</title>
    <s:head/>
</head>
<body>
<h3>使用s:doubleselect生成级联下拉列表框</h3>
<!-- 创建一个复杂的Map对象,key为普通字符串,value为集合 -->
<s:set name="bs" value="#{'李刚': {'疯狂Java讲义',
    '轻量级Java EE企业应用实战','疯狂iOS讲义'},
    'David': {'JavaScript: The Definitive Guide'},
    'Johnson': {'Expert One-on-One J2EE Design and Development'}}"/>
<!-- 使用Map对象来生成级联列表框 -->
<s:form action="x">
    <s:doubleselect
        label="请选择您喜欢的图书"
        size="3"
        name="author" list="#bs.keySet()"
        doubleList="#bs[top]"
        doubleSize="3"
        doubleName="book"/>    
</s:form>
</body>
</html>

2 测试

Struts标签库doubleselect标签实战

上一篇:Struts标签库的optgroup实战


下一篇:Struts基于map的类型转换