ITPub博客

首页 > 数据库 > 数据库开发技术 > Accessing Java Constants from JSTL or OGNL

Accessing Java Constants from JSTL or OGNL

原创 数据库开发技术 作者:zenzuguo 时间:2010-02-25 12:09:51 0 删除 编辑

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

然后在使用的时候

<%@ taglib uri="/tags/cons" prefix="cons" %>

在header.jsp中

<%-- Put constants into request scope --%>

然后在使用的地方

constantstaglib.zip

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/106285/viewspace-1031434/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 连体衣
请登录后发表评论 登录
全部评论

注册时间:2012-12-30

  • 博文量
    84
  • 访问量
    828869