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

  • 相关阅读:
    cocos2d-android学习四 ---- 精灵的创建
    Think In java 笔记一
    管理文件夹
    Android Studio Mac 快捷键整理分享
    协同过滤
    POJ 3281(Dining-网络流拆点)[Template:网络流dinic]
    JS经常使用表单验证总结
    js中的Call与apply方法
    (转)WPF控件开源资源
    五年北京,这个改变我命运的城市,终于要离开了(转)
  • 原文地址:https://www.cnblogs.com/db2zos/p/2304164.html
Copyright © 2011-2022 走看看