zoukankan      html  css  js  c++  java
  • 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三者之间要完全对应,否则会出现下拉框有内容,但显示空白

  • 相关阅读:
    KVC
    MRC&ARC
    网络基础
    沙盒
    GCD深入了解
    iOS 架构模式MVVM
    iOS 源代码管理工具之SVN
    iOS给UIimage添加圆角的两种方式
    Objective-C 中,atomic原子性一定是安全的吗?
    iOS Block循环引用
  • 原文地址:https://www.cnblogs.com/db2zos/p/2304164.html
Copyright © 2011-2022 走看看