日期:2014-05-16 浏览次数:20580 次
public class Constants implements Serializable { public static final String CONSTANT_A= "ABC"; ... }
<c:out value="${Constants.CONSTANT_A}"/>
<form:select path="gender"> <form:option value="-" label="--Please Select"/> <form:options items="${CodeTable.Gender}" itemValue="codeValue" itemLabel="codeName"/> </form:select>
public class ApplicationScopeLoader extends WebApplicationObjectSupport { ... /** code table service */ private final CodeTableLoaderService codeTableLoaderService = ApplicationContextManager .getBean("codeTableLoaderService",CodeTableLoaderService.class); private final static String CODE_TABLE_CONTEXT_NAME = "CodeTable"; protected void initApplicationContext() { try { //build constants and put it to the application scope this.buildConstants(); //build code table and put it to the application scope this.buildCodeTables(); } catch (Exception e) { e.printStackTrace(); } } /** * build code tables * each code table will be group by the type * for example, if there is a code table type 'gender' * then will be put to */ private void buildCodeTables(){ String[] codeTypes = codeTableLoaderService.loadAllCodeTypes(); for(String codeType: codeTypes){ this.buildOneCodeTableByCodeType(codeType); } } /** * extract given codes to a sub array of codes by code type * @param codes * @return */ private void buildOneCodeTableByCodeType(String codeType){ Map<Object,Object> codeMap = new HashMap<Object,Object>() { private static final long serialVersionUID = -1759893921358235848L; /** * get from the service, not raw data for avoiding non-refresh issue */ public Object get(Object key) { return codeTableLoaderService.ge