浏览 12649 次
精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-05-15
我所看到的参考实现: 在JForum中有这样的参考实现: JForum.getContext().put("I18n", I18n.getInstance()); ${I18n.getMessage("Bookmarks.reallyDelete")} 如果要这样的话,我势必要注册所有的工具类包了? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-05-15
文档上有,大概是
static['com.example.You'].doSomeThing() |
|
返回顶楼 | |
发表时间:2006-05-15
OGNL 用法
ValueStack 中的对象 : @vs@someVar or @vs@someMethod 非 ValueStack : @somepacke.someVar or @somepacke.someMethod |
|
返回顶楼 | |
发表时间:2006-05-15
没有试通:(能否说得具体一些?多谢
chenggn 写道 文档上有,大概是
static['com.example.You'].doSomeThing() |
|
返回顶楼 | |
发表时间:2006-05-15
呵呵,解决了,多谢各位提示,解决方案如下:
##定义配置文件 freemarkerstatic.properties _Validator=com.longyou.util.Validator _Functions=com.longyou.util.Functions _EscapeUtils=com.longyou.util.EscapeUtils //Java类实现 Configuration config = new Configuration();; BeansWrapper wrapper = BeansWrapper.BEANS_WRAPPER; wrapper.setExposureLevel(BeansWrapper.EXPOSE_ALL);; InputStream in = null; try{ in = ClassLoaderUtils.getResourceAsStream("/freemarkerstatic.properties", FreemarkerUtils.class);; if(in != null);{ Properties props = new Properties();; props.load(in);; Enumeration en = props.keys();; String name, value; TemplateHashModel staticModels = wrapper.getStaticModels();; while(en.hasMoreElements(););{ name = (String);en.nextElement();; value = props.getProperty(name);; TemplateHashModel tempStatics = (TemplateHashModel); staticModels.get(value);; config.setSharedVariable(name, tempStatics);; } } }catch(Exception ex);{ log.error("Error while loading freemarker settings from /freemarkerstatic.properties", ex);; }finally{ if(in != null);{ try{ in.close();; }catch(Exception ex);{ ex.printStackTrace();; } in = null; } } config.setObjectWrapper(wrapper);; //调用代码 ${_Functions.toUpperCase("Hello");}<br> ${_EscapeUtils.escape("Java视线论坛");} //输出结果 HELLO Java%u89C6%u7EBF%u8BBA%u575B |
|
返回顶楼 | |
发表时间:2006-05-16
按照你的方法,我没有成功,是否还有其它人按照上述方法成功的?
|
|
返回顶楼 | |
发表时间:2006-05-17
http://freemarker.sourceforge.net/docs/pgui_misc_beanwrapper.html
Accessing static methods |
|
返回顶楼 | |
发表时间:2006-05-27
我上次发了一个帖子,看来被版主删了.看来不允许转英文原文的.最直接的方法就是用valuestack.写法类如:
${stack.findValue("@package.ClassName@method")} |
|
返回顶楼 | |