• s:select 在structs中的用法


    1: 在jsp中写死了options的值, 注意,这时候list后面的"#"必不可少,而且非常重要

    <s:select name="ecId" list="#{0:'NDS,1 EC,2 DB2',1:'NDS,4 EC,4 DB2'}" label="Select a EC Type" 
    />

    2: 用hashmap来设置值:

    在jsp中:

    		
    <s:select name="ecId" list="ecMap"
    listKey="key"  listValue="value"  
    headerKey="" headerValue="Select ecType"
    label="Select a EC Type" 
    />
    

    在java中:

    		ecMap = new HashMap();
    		ecMap.put(0, "NDS,1 EC,2 DB2");
    		ecMap.put(1, "NDS,4 EC,4 DB2");

    3: 用bean的list来设置值:

    在jsp中:

     
    <s:select name="ecId" list="ecTypeList"
    listKey="id"  listValue="type"  
    headerKey="" headerValue="Select ecType"
    label="Select a EC Type" 
    /> 
    

    在java bean文件中设置属性:

            private String id;
    	private String type;
    	
    	public EcType(String id,String type){
    		this.setId(id);
    		this.type = type;
    	}
    
    	public void setId(String id) {
    		this.id = id;
    	}
    
    	public String getId() {
    		return id;
    	}
    
    	public void setType(String type) {
    		this.type = type;
    	}
    
    	public String getType() {
    		return type;
    	}

    在action文件中添加list:

    	private ArrayList<EcType> ecTypeList;
    	public void setEcName(String ecName) {
    		this.ecName = ecName;
    	}
    	public String getEcName() {
    		return ecName;
    	}
    	public void setEcTypeList(ArrayList<EcType> ecTypeList) {
    		this.ecTypeList = ecTypeList;
    	}
    	public ArrayList<EcType> getEcTypeList() {
    		return ecTypeList;
    	}

    第三种方法一定要确定jsp,bean,action三者之间要完全对应,否则会出现下拉框有内容,但显示空白

  • 相关阅读:
    NLB网路负载均衡管理器详解
    Nginx配置详解
    Nginx代理功能与负载均衡详解
    .Net使用RabbitMQ详解
    说说面向服务的体系架构SOA
    .Net中的RealProxy实现AOP
    搭建自己的Nuget服务器
    VMware虚拟网络连接模式详解(NAT,Bridged,Host-only)
    JsonUtils
    Linux三剑客
  • 原文地址:https://www.cnblogs.com/db2zos/p/2304164.html
Copyright © 2020-2023  润新知