struts2 和 freemarker 模板

发布于 2024-11-06 07:09:18 字数 532 浏览 1 评论 0原文

我在我的网络应用程序上使用struts2,在一个jsp文件中,我使用“迭代器”以表单形式显示3个数组列表。

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

这是我的 websphere 控制台上的日志:

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

在页面出现之前我已经有近 9000 行这样的行了。

我尝试使用 prop 创建一个文件“freemarker.properties”:

template_update_delay=60000

还尝试在 WEB-INF 上的源根目录中提取“template/simple”...什么都没有!

你有什么想法吗?

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

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.

here is the logs i have on my websphere console :

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

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

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

template_update_delay=60000

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

do you have any idea ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢好甜 2024-11-13 07:09:18

在缓存中找不到模板

模板文件夹应复制到 WEB_APP root 而不是 WEB-INF
我的建议:将模板文件夹重命名为 templates 以区别于默认值。

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

参考Struts2的性能调优

  1. 关闭日志记录和 devMode
    确保关闭 Freemarker 日志记录(尤其是 Freemarker 生成大量的日志记录)。

  2. 尝试使用 Freemarker 等效项而不是使用 JSP 标记
    应替换为 ${foo} (类型转换除外),对 迭代器有很大的性能提升.

Could not find template in cache

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" />

Refer to Performance tuning of Struts2 :

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

  2. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文