本文是一篇关于模板拷贝的帖子

The following are some tips and tricks to squeeze the most performance out of Struts 2.

Important OGNL update

For Struts 2 versions before 2.3: the OGNL version 3.0.3 library is a drop-in replacement for older OGNL jars, and provides much better performance. See the following Jira issue for more information:https://issues.apache.org/jira/browse/WW-3580

Turn off logging and devMode.   关掉志日与开辟式模

devMode allows reloading of configuration and validation related files, but because they happen on each request, this setting will totally kill your performance.

When using logging, make sure to turn off logging (esp. Freemarker generates a LOT of logging), and check if a level is enabled before printing it, or you will get the cost of the String parsing/concatination anyways.

Use the Java Templates  应用Java模板

If you use the simple theme, and do not overwrite any of the FreeMarker templates, consider using the java templates, which provide a drop in replacement for most tags, and are a lot faster than the regular tags.

Do not use interceptors you do not need. 不要应用拦截器,除非你真的要需

If you do not require a full stack of interceptors for an Action, then try using a different one (basicStack), or remove interceptors you do not need. Remove the I18nInterceptor interceptor if you don't need it, as it can cause a session to be created.

Use the correct HTTP headers (Cache-Control & Expires). 返回应用准确的HTML头部

When returning HTML views, make sure to add the correct headers so browsers know how to cache them.

Copy the static content from the Struts 2 jar when using the Ajax theme (Dojo) or the Calendar tag.拷贝struts jar包静态文件出来

Struts 2 uses some external javascript libraries and cascading stylesheets for certain themes and tags. These by default are located inside the Struts 2 jar, and a special filter returns them when requesting a special path (/struts). Although Struts 2 can handle these requests, an application/servlet container is not optimized for these kind of requests. Consider moving these .js and .css files to a seperated server (Lighttpd, Apache HTTPD, ..).

每日一道理

“多难兴才”曾一度被人定为规律。请看:屈原被放逐而作《离骚》;司马迁受宫刑而作《史记》;欧阳修两岁丧父笃学而成才;曹雪芹举家食粥而写出了不朽的《红楼梦》;越王勾践卧薪尝胆而雪洗国耻;韩信遭胯下辱而统率百万雄兵……他们都是在与逆境搏斗中成为伟人的!

Create a freemarker.properties file in your WEB-INF/classes directory. 置设freemarker.properties模板更新延时间时

Create the freemarker.properties file and add the following setting (or whatever value you deem fitting):

template_update_delay=60000

This value determines how often Freemarker checks if it needs to reloads the templates from disk. The default value is 500 ms. Since there is no reason to check if a template needs reloading, it is best to set this to a very large value. Note that this value is in seconds and freemarker will convert this value to milliseconds.

Enable Freemarker template caching  关闭Freemarker模板缓存

As of Struts 2.0.10, setting the property struts.freemarker.templatesCache to true will enable the Struts internal caching of Freemarker templates. This property is set to false by default.

In Struts versions prior to 2.0.10, you had to copy the /template directory from the Struts 2 jar in your WEB_APP root to utilize Freemarker's built in chaching mechanism in order to achieve similar results.

The built in Freemarker caching mechanism fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.

When overriding a theme, copy all necessary templates to the theme directory. 盖覆主题时,拷贝所以模板(含父模板)

There's a performance cost when a template cannot be found in the current directory. The reason for this is that Struts 2 must check for a template in the current theme first before falling back to the parent theme. In the future, this penalty could be eliminated by implementing a missing template cache in Struts 2.

Do not create sessions unless you need them.不要创立Session,除非你要需,国际化拦截器会创立Session

Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created (Seehttp://forums.opensymphony.com/thread.jspa?messageID=5688 for details). The I18nInterceptor interceptor can create sessions, so make sure you remove it, if you don't need it.

When using Freemarker, try to use the Freemarker equivalent rather than using the JSP tags.应用模板时用采${}式方

Freemarker has support for iterating lists, displaying properties, including other templates, macro's, and so on. There is a small performance cost when using the S2 tags instead of the Freemarker equivalent (eg. should be replaced by ${foo}).

文章结束给大家分享下程序员的一些笑话语录: 看新闻说中国输入法全球第一!领先了又如何?西方文字根本不需要输入法。一点可比性都没有。

java pdf添加便利贴_模板拷贝【便利贴】Struts性能优化相关推荐

  1. java pdf添加透明水印_如何在PDF文件中添加透明水印

    原标题:如何在PDF文件中添加透明水印 有些文件添加水印,但是又不想水印影响文件的使用有时候会设置透明水印,那么PDF怎么设置透明水印呢,应该有很多的小伙伴们都很好奇应该怎么做吧,接下来就为大家分享一 ...

  2. java pdf添加透明水印_如何使用PDF编辑工具在PDF文件中添加透明水印

    PDF 文件在修改编辑的时候会使用到 PDF 编辑工具,不管是工 作中还是生活中,都会使用到 PDF 文件,当我们需要给 PDF 文件添 加透明水印时,该怎么操作呢,是不是有很多的小伙伴也很好奇, 那 ...

  3. java pdf添加便利贴_win10系统便利贴添加到桌面的操作方法

    很多小伙伴都遇到过对win10系统便利贴添加到桌面进行设置的困惑吧,一些朋友看过网上对win10系统便利贴添加到桌面设置的零散处理方法,并没有完完全全明白win10系统便利贴添加到桌面的操作方法非常简 ...

  4. java -PDF添加文本水印与图片水印

    java pdf添加水印文本及图片文本 PDF文件添加文本水印: private static int interval = 30;public static voidwaterMark(String ...

  5. kali2020进入单模式_蚂蚁集团技术专家山丘:性能优化的常见模式及趋势

    陈显铭(山丘) 读完需要 6分钟 速读仅需 2 分钟 陈显铭,花名山丘,就职于蚂蚁集团,对分布式应用架构.服务化.性能优化等有深入的理解.参与支付宝支付链路核心系统,设计.调优应用系统关键能力, 高效 ...

  6. golang string 加号连接性能慢_面试必备:浅析C#性能优化的若干种方法

    浅析C#性能优化的若干种方法 1.1 垃圾回收 垃圾回收解放了手工管理对象的工作,提高了程序的健壮性,但副作用就是程序代码可能对于对象创建变得随意. 1.1.1 避免不必要的对象创建 由于垃圾回收的代 ...

  7. 使用js在桌面上写一个倒计时器_论一个倒计时器的性能优化之路

    原文发表于 2018.05.25,搬运自个人博客. 引子 回顾这半年,扛需求能力越来越强,业务代码也是越写越多.但稍一认真看看这些当时为了满足快速上线所码的东西,问题其实还是不少.这次就从一个简单的计 ...

  8. java pdf添加便利贴_想在桌面中添加便利贴,教你使用桌面便利贴进行信息提示...

    有时,我们的工作非常繁重,每天需要涉及很多的工作任务,这时,我们可以在电脑桌面中设置便利贴,以便在合适的时候提示我们这些信息,让我们更好的管理自己的时间,避免出现工作延误或遗忘问题,给我们的工作生活带 ...

  9. java pdf添加便利贴_电脑win10的便利贴在哪里|win10如何添加便利贴

    Win7系统的便签工具叫便笺,升级到win10系统后,便签工具叫做便利贴,也叫Sticky notes.别看名称不一样,其实功能都是一样的,都能用来记录一些东西,然后随时可以进行查看.这篇文章是PE吧 ...

最新文章

  1. 【Github上有趣的项目】TensorKart 自动驾驶马里奥赛车(玩不了)
  2. 面试的27个经典问题
  3. Actuator提供的endpoint
  4. 博弈论:别人的想法(文末送书!)
  5. 【算法分析与设计】计数排序
  6. 最大化 AIX 上的 Java 性能,第 3 部分: 更多就是更好
  7. 计算机动漫与游戏制作画画教学,科普下动漫制作必须会画画吗
  8. matlab2c使用c++实现matlab函数系列教程-sum函数
  9. GIS应用技巧之利用DEM制作三维立体图
  10. android gallery效果,Android RecyclerView封装的Gallery效果控件,android galleryview
  11. Linux基础开发工具
  12. linux+psp+模拟器下载,PSP1.5模拟器全教程+最新版本下载(最终版)
  13. 计算机远程用户关机指令,有哪些远程关机命令?如何用向日葵进行远程关机电脑?...
  14. IK分词器原理研磨及源码改造,更适用生产
  15. windows10和linux流畅,《古墓丽影10:崛起》Linux平台与Windows平台流畅度对比
  16. 计算机网络笔试面试题目大全
  17. MOS管和三极管的工作原理对比
  18. 恐怖丛林肉搏怎么玩 星星系统
  19. 微信小程序页面间通信实现pub-sub
  20. 小学奥数思维训练题(十二)

热门文章

  1. 三级linux网络管理及应用技术,浙江省大学计算机三级Linux网络管理及应用.doc
  2. 我们在配置OpenAL的时候到底做了什么
  3. 俄罗斯方块双人对战版
  4. 计算机网络图标不见了怎么为,网络连接图标不见了,小编教你网络连接图标不见了怎么办...
  5. ios 设置主题的三方库
  6. 人脸识别毕业设计python_25 行 Python 代码毕业设计实现人脸识别
  7. keepalived应用:漂移IP的实现
  8. C# 调用高德地图API获取经纬度以及定位,JS获取定位【万字详解附完整代码】
  9. DJSF1352RN直流电能表在某新加坡光伏储能系统中的应用
  10. 基于springboot的智慧物业管理系统的设计与实现(前后端分离)