カスタムラベルを使ってselectドロップボックスを作成します。


私たちは日常的に開発していますが、時々1ページの多くのSelectのコンボボックスに遭遇します。コンボボックスの内容は辞書の種類によって様々なデータを入手して、プルダウンリストとして展示しています。このように煩わしいです。毎回、ドロップダウンオプションを初期化するために、jspTagのカスタムタグを使って完成できます。
  • カスタムラベル
  • /**
     * 

    * DictSelectTag *

    * JspTag * @author jianzhang11 * @version 1.0 * @desc * @Date: 2016/5/18 18:43 * @since 1.0 */ public class DictSelectTag extends TagSupport{ // service private BaseDicService baseDicService = SpringContextHolder.getBean("baseDicService"); private String id; private String name; private String value; private String type; /** * CSS */ private String cssStyle; @Override public String getId() { return id; } @Override public void setId(String id) { this.id = id; } public void setName(String name) { this.name = name; } public void setValue(String value) { this.value = value; } public void setType(String type) { this.type = type; } public void setCssStyle(String cssStyle) { this.cssStyle = cssStyle; } /** * * @return * @throws JspException */ @Override public int doEndTag() throws JspException { JspWriter out = pageContext.getOut(); List dicList = baseDicService.findBaseDicsByType(type); StringBuffer sb = new StringBuffer(); sb.append(""); try { out.write(sb.toString()); } catch (IOException e) { e.printStackTrace(); } return TagSupport.EVAL_PAGE; } }
  • 新規tldファイル構成ラベル
  • 
    
    
    
        1.0
        dict
        http://iflytek.com/dict_tag
       
       
        
            Renders an HTML 'select' element. Supports databinding to the selected option.
            select
            com.iflytek.esociety.common.tag.DictSelectTag
            JSP
            
                id
                false
                true
            
            
                value
                false
                true
            
            
                name
                true
                true
            
            
                type
                true
                true
            
            
                cssStyle
                false
                true
            
        
    
    
    
  • ページ呼び出し
  •