`

Struts 2的开发模式即struts2 中的constant 简介

 
阅读更多
下面是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"/>


分享到:
评论

相关推荐

    struts2开发遇到的问题

    以上就是Struts2开发过程中常见的问题和解决策略。在实际开发中,理解Struts2的工作原理、配置细节以及日志信息对定位和解决问题至关重要。此外,保持更新至最新稳定版本的Struts2框架,遵循最佳实践,以及使用IDE的...

    Struts2配置精要之常量constant配置详解(包括零配置Convention 的常量)

    在Struts2中,配置是至关重要的部分,它允许开发者自定义框架的行为以适应具体项目需求。本文将深入探讨Struts2中的常量配置,包括基本的XML配置以及零配置的Convention模式下的常量设定。 首先,让我们了解Struts2...

    Struts2\constant应用

    **作用:** 指定Struts2中的Action由哪个容器创建。 **配置示例:** ```xml &lt;constant name="struts.objectFactory" value="spring" /&gt; ``` **解释:** 通过此配置,Struts2框架会使用Spring容器来创建Action实例,...

    Struts2_s2-016&017&ognl2.6.11_patch漏洞补丁

    struts.xml文件中新增以下内容: &lt;!-- 为修复struts2 s2-016、s2-017漏洞,重写DefaultActionMapper --&gt; &lt;bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="myDefaultActionMapper" class=...

    Struts2 开发

    在Struts2中,`autoComplete`标签是一个非常实用的功能,用于实现自动完成或自动填充的效果,常见于搜索框或输入字段,提高用户体验。这个标签通常与JavaScript和AJAX技术结合使用,动态从服务器获取匹配的数据并...

    struts2 Https 配置

    在Struts2中配置HTTPS主要涉及以下几个步骤: 1. **配置服务器**:首先,你需要在服务器端(如Tomcat、Jetty等)启用HTTPS。这通常涉及到修改服务器的配置文件(如Tomcat的`server.xml`),添加一个监听443端口的...

    struts2开发教程

    在Struts2中,Action不再需要继承`org.apache.struts.action.Action`类,而是继承自`com.opensymphony.xwork2.ActionSupport`。例如,创建一个简单的`FirstAction`类: ```java package action; import ...

    struts2初始使用环境配置

    -- 开发模式,便于调试 --&gt; &lt;package name="default" namespace="/" extends="struts-default"&gt; &lt;result name="success"&gt;/HelloWorld.jsp &lt;/struts&gt; ``` 编写Action类。Action类是处理用户请求的业务逻辑...

    Struts2课堂学习总结

    3. **Struts2配置**:在`struts.xml`文件中,`&lt;constant&gt;`标签用于配置常量,例如`struts.devMode`设置为`true`可开启开发模式,方便热部署。`&lt;package&gt;`、`&lt;action&gt;`和`&lt;result&gt;`标签定义了Action和结果页面的映射...

    struts2文件上传下载源代码

    在Struts2中,文件上传和下载是常见的功能需求,特别是在处理用户交互和数据交换时。这篇博客文章提供的"struts2文件上传下载源代码"旨在帮助开发者理解和实现这些功能。 文件上传功能允许用户从他们的设备上传文件...

    struts2学习笔记(完美总结)——转自OPEN经验库

    配置文件中,`&lt;constant&gt;`标签用于设置全局常量,如`struts.devMode`控制开发模式。`&lt;package&gt;`标签用于组织Action,解决重名问题,并可以继承其他包的配置,实现代码复用。 **四、OGNL (Object-Graph Navigation ...

    struts2入门教程及struts2集成spring

    4. **Action类设计**:Action类需要实现Spring的`ApplicationContextAware`接口,以便在Struts2中获取Spring的ApplicationContext,从而能够注入其他服务。例如: ```java public class ExampleAction implements ...

    struts2_rest整合完整例子

    在Struts2中整合REST,主要涉及到配置Action和URL映射,使得HTTP方法(如GET、POST)能对应到不同的Action执行逻辑。Struts2的Restful插件提供了这种支持,它允许我们使用动词和路径来定义Action,例如`/{resource}/...

    Struts2最新漏洞升级2.3.32版本

    struts2-convention-plugin-2.3.32.jar struts2-core-2.3.32.jar struts2-spring-plugin-2.3.32.jar xwork-core-2.3.32.jar 2、删除上面原有的低版本jar 3、修改 WEB-INF\classes 目录下struts.xml 文件,...

    eclipse for javaee配置web开发环境(struts2+servlet+sping)字体.doc

    这里设置了Struts2的开发模式(devMode)为true,以便在开发过程中获取更详细的错误信息。 **5. 部署与运行** 将项目部署到Tomcat服务器,然后在浏览器中输入`http://localhost:8888/yourProjectName/Hello`(替换...

    struts2框架下的文件上传

    在Struts2中,文件上传是一个常见的需求,可以帮助用户从客户端上传文件到服务器。本文将详细讲解Struts2框架下三种不同的文件上传方式:copy模式、字节流上传和字符流上传。 1. Copy模式文件上传: Copy模式是...

    配置struts2的步骤

    为了提高开发效率,可以在`struts.xml`中开启开发模式,这将使得Action的更改无需重启服务器即可生效。具体配置如下: ```xml &lt;constant name="struts.devMode" value="true"/&gt; ``` 通过设置`struts.devMode`为`...

    struts 2. 5.2解决中文乱码

    3. **Struts 2配置**:在Struts 2的配置文件`struts.xml`中,可以全局设定默认的编码方式: ```xml &lt;constant name="struts.i18n.encoding" value="UTF-8"/&gt; &lt;constant name="struts.action.extension" value=",...

    struts2图片上传并预览

    确保`struts2-core`和`struts2-convention-plugin`以及`struts2-file-uploading-plugin`在你的类路径中。 2. 配置struts.xml:在`struts.xml`配置文件中,启用文件上传,设置`struts.multipart.saveDir`属性指定...

Global site tag (gtag.js) - Google Analytics