实际开发中或产品部署中开发模式(devMode)的设定

来源:互联网 发布:白鲨外设淘宝店 编辑:程序博客网 时间:2024/05/18 00:51
在实际应用开发或者是产品部署的时候,对应着两种模式:开发模式(devMode)和产品模式(proMode);在一些服务器或者框架中也存在着这两种模式,例如:tomcat、struts2等(其他的有待学习,呵呵),在这两种不同的模式下,他们运行的性能方面有很大的差异。
在struts.properties或者struts.xml中有devMode的配置,在devMode被激活的模式下,能够明显的提高开发效率,它会提供更多的日志或着debug信息。当然提高开发效率,在性能方面会付出一定的代价。所以struts默认的是非开发模式。
便于Struts2应用的开发与调试 ,可以让Struts2工作在开发模式下,
这样可以在不重新装载应用的前提下实现
? 在请求之间自动重新载入struts.xml文件的信息。
? 在请求之间自动重新载入资源文件。
? 在请求之间自动重新载入校验文件。
工作在开发模式下,Struts2可以输出更多的运行时的调试信息,这样有
助于跟踪调试程序。


要使Struts2工作在开发模式下,可以在struts.xml文件中加入:
<constant name="struts.devMode" value="true" />


另外,也可以在src目录下新建一个文件struts.properties,打开编辑,加入以下语句:
struts.devMode=true                           #设置为开发模式
struts.i18n.reload=true                       #国际化自动重新部署
struts.configuration.xml.reload=true   #重新加载xml文件





下面是4个开发模式常用配置的简介---

<!-- 开启使用开发模式,详细错误提示 -->    <!-- <constant name="struts.devMode" value="true"/>-->    <!-- 指定每次请求到达,重新加载资源文件 -->    <!-- <constant name="struts.i18n.reload" value="true"/>-->    <!-- 指定每次配置文件更改后,自动重新加载 -->    <!-- <constant name="struts.configuration.xml.reload" value="true"/>-->    <!-- 指定XSLT Result使用样式表缓存 -->    <!-- <constant name="struts.xslt.nocache" value="true"/>-->



其他模式
<!-- 指定Web应用的默认编码集,相当于调用 HttpServletRequest的 setCharacterEncoding方法 --><constant name="struts.i18n.encoding" value="UTF-8" /><!--该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts 2处理。如果用户需要指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开。--><constant name="struts.action.extension" value="do" /><!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 --><constant name="struts.serve.static.browserCache " value="false" /><!-- 当 struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 --><constant name="struts.configuration.xml.reload" value="true" /><!-- 开发模式下使用,这样可以打印出更详细的错误信息 --><constant name="struts.devMode" value="true" /><!-- 默认的视图主题 --><constant name="struts.ui.theme" value="simple" /><!-- 该属性指定Struts 2中的action由Spring容器创建 --><constant name="struts.objectFactory" value="spring" />





其他常量
<constant name="struts.action.excludePattern" value="/ShitServlet"/><constant name="struts.enable.DynamicMethodInvocation" value="false" /><constant name="struts.multipart.maxSize" value="1024000"/><!--最大上传1M的图片--><constant name="struts.multipart.saveDir" value="D:/temp"/><!--临时目录--><constant name="struts.convention.result.path" value="/" /><constant name="struts.convention.classes.reload" value="true" /><constant name="struts.devMode" value="true" /><constant name="struts.ui.theme" value="simple"/><constant name="struts.i18n.encoding" value="UTF-8"/><constant name="struts.custom.i18n.resources" value="message"/><constant name="struts.locale" value="zh-cn"/><!--可上传的图片后缀--><constant name="com.chinacnd.allowed.images" value="gif,jpeg,jpg,png,bmp"/>



本文从网上收集整理