struts2和freemarker模板 [英] struts2 and freemarker template

查看:62
本文介绍了struts2和freemarker模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Web应用程序上使用struts2,在一个jsp文件中,我使用迭代器"的形式显示3个arraylist.

i use struts2 on my web app, in one jsp file i display 3 arraylist in a form using "iterator".

当我使用tomcat启动我的应用程序时,一切正常.但是我想使它与websphere6.1一起使用,但是当我现在启动它时,该页面需要20到30秒才能显示出来,而tomcat则不到1秒钟.

when i launch my app with tomcat everything works fine. but i would like to make it works with websphere6.1, but when i launch it now the page take 20-30 second to appears, with tomcat it was lass than 1 second.

这是我在Websphere控制台上拥有的日志:

here is the logs i have on my websphere console :

(freemarker.cache 81)在缓存中找不到模板,正在创建新模板; id = [template/simple/form.ftl [fr_FR,UTF-8,parsed]]

(freemarker.cache 81 ) Could not find template in cache, creating new one; id=[template/simple/form.ftl[fr_FR,UTF-8,parsed] ]

在页面出现之前,我几乎有9000行.

i have almost 9000 lines of this kind before page appears.

我尝试使用prop创建文件"freemarker.properties":

i tried to create a file "freemarker.properties" with prop :

template_update_delay=60000

还尝试在我的源根目录中的WEB-INF上提取模板/简单"……什么都没有!

also tried to extract the "template/simple" in my source root, on WEB-INF... nothing !

你有什么想法吗?

推荐答案

在缓存中找不到模板

Could not find template in cache

模板文件夹应复制到WEB_APP root而不是WEB-INF.
我的建议:将模板文件夹重命名为templates以便与默认文件夹区分开.

The template folder should copy to WEB_APP root instead of WEB-INF.
My suggestion : Rename the template folder to templates for distinguished from default.

<constant name="struts.ui.templateDir" value="templates" />
<constant name="struts.ui.theme" value="simple" />


请参阅Struts2的性能调整:

  1. 关闭日志记录和devMode
    确保关闭 Freemarker记录 (尤其是Freemarker生成很多日志).

  1. Turn off logging and devMode
    Make sure to turn off Freemarker Logging (esp. Freemarker generates a LOT of logging).

尝试使用等效的Freemarker而不是使用JSP标记
<s:property value="foo"/>应该用${foo}替换(类型转换除外),这对 iterator 的性能有很大的增强.

Try to use the Freemarker equivalent rather than using the JSP tags
<s:property value="foo"/> should be replaced by ${foo} (except for type conversion), great performancing enhancing for iterator.

这篇关于struts2和freemarker模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆