struts2 and freemarker template

2019-08-03 06:37发布

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 ??

1条回答
乱世女痞
2楼-- · 2019-08-03 06:52

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.

查看更多
登录 后发表回答