Accessing Java Constants from JSTL or OGNL
Accessing Java Constants from JSTL
Even there could be many variations to the above code, more creative, funnyer or smarter, this is not my recommended solution. Following the Principle No. 6 from our internal guide, the “DRW concept” (don’t reinvent the wheel :) ), the solution is simple: the unstandard tag library from Apache. Here’s how to use it: and later in you code, an expression like: ${users[Constants.NAME]}
and later in you code, an expression like:
${users[Constants.NAME]}
OGNL - Getting Static Fields
Getting Static Fields
You can refer to a static field using the syntax @class@field. The class must be fully qualified.
用appfuse的方法使用常量定義ConstantsTag, constants.tld
然後在使用的時候
在header.jsp中
然後在使用的地方
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/106285/viewspace-1031434/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Struts標籤、ognl表示式、el表示式、jstl標籤庫這四者之間JS
- Java for Web學習筆記(二五):JSTL(1)使用JSTLJavaWeb筆記JS
- OGNL詳解
- ognl總結
- expo-constants 常量
- Java Web(七) JSTL標籤庫JavaWebJS
- 強大的ognl
- Java from SUN & Son of JavaJava
- Accessing Frequently Used Dictionary ObjectsObject
- Accessing Internal Members in the UNO FrameworkFramework
- JSTLJS
- 使用Jstl異常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot&nbsJSHTTPJava
- From Java EE security to AcegiJava
- Error accessing PRODUCT_USER_PROFILEError
- EL&JSTL26_JSTL標籤3JS
- JSTL教程-JS
- FROM JAVA BUILDERS TO KOTLIN DSLSJavaUIKotlin
- Shader變體大殺器:Specialization constants
- JSTL標籤JS
- 菜鳥學Java(三)——JSTL標籤之核心標籤JavaJS
- Java | 在 Java 中執行動態表示式語句: 前中字尾、Ognl、SpEL、Groovy、Jexl3Java
- Struts2 OGNL動態配置result(十八)
- Struts2的OGNL標籤詳解
- JSP三(JSTL)JS
- JSTL基礎用法JS
- jstl處理字串JS字串
- jstl處理日期JS
- JSP&&EL&&JSTLJS
- jstl 寫的分頁JS
- JSTL標籤工具類JS
- JSTL 每天積極向上JS
- jstl forEach遍歷JS
- jstl 時間data格式JS
- jstl格式化日期JS
- JSTL的相關使用JS
- JSTL取list 長度JS
- Remove Duplicates from Sorted List leetcode javaREMLeetCodeJava
- Remove Duplicates from Sorted Array leetcode javaREMLeetCodeJava