Struts的常量与全局配置
来源:互联网 发布:合并报表软件 编辑:程序博客网 时间:2024/05/17 06:24
Struts常量
Struts中默认访问后缀:
Struts1中默认访问后缀是*.do
Struts2中默认访问后缀是*.action
如何修改默认访问后缀
1、Struts2的.action访问后缀在哪里定义?
Struts-core-2.3.4-1.jar/org.apache.struts/default.propertles
Struts.action.extendsion=action..
2、在struts.xml中通过常量修改
<constant name=”struts.action.extension” value=”action,do,”></constant>
指定访问后缀为action/do/没有访问后缀都可以
Value=”action,do,” 访问后缀:action/do/不带后缀
Value=”action,do” 访问后缀:action或do
Value=”action” 访问后最:action
常量:
a、 指定默认编码集,作用于HttpServletRequest的setCharacterEncoding方法 和freemarker 、velocity的输出(post有效)
<constant name="struts.i18n.encoding" value="UTF-8"/>
b、自定义后缀修改常量
<constant name="struts.action.extension" value="do"/>
c、设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭
<constant name="struts.serve.static.browserCache" value="false"/>
d、当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开
<constant name="struts.configuration.xml.reload" value="true"/>
e、开发模式下使用,这样可以打印出更详细的错误信息
<constant name="struts.devMode" value="true" />
f、默认的视图主题
<constant name="struts.ui.theme" value="simple" />
g、与spring集成时,指定由spring负责action对象的创建
<constant name="struts.objectFactory" value="spring" />
h、该属性设置Struts 2是否支持动态方法调用,该属性的默认值是true。如果需要关闭动态方法调用,则可设置该属性为false
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
作用:
当我们配置**.xml文件的action时,可以不配置method,可以直接通过访问地址访问指定的method
如:
我问需要访问hello-->login()
方法一:配置method
http://localhost:8080\StrutStu\hello
方法二:通过动态方法访问
http://localhost:8080\StrutStu\hello!login
i、上传文件的大小限制
<constant name="struts.multipart.maxSize" value=“10701096"/>
配置全局跳转视图
<!-- 配置全局跳转视图 --><global-results><result name="login">/success.jsp</result></global-results><action name="hello" class="cn.lfsenior.c_config.HelloWord" method="login" ><!-- 返回结果标记login对应的页面在当前action中没有配置 所以会去找全局配置是否有login标记对应的页面 --></action>
配置各项默认值
<!-- 配置各项默认值 --> <!-- name 只配置了访问路径名称 class 默认执行的action在struts-default有配置 <default-class-ref class="com.opensymphony.xwork2.ActionSupport" /> method 默认为execute 默认的方法execute返回值为success,对应的页面去全局视图找。 --> <action name="test"></action><!-- 什么情况不配置class? 即处理的aciton --><!-- 答案: 当只是需要跳转到WEB-INF下资源的时候。(WEB-INF下的资源只对服务端开发,不对客户端开发。所以只能通过转发访问,不能通过重定向访问) --> <action name="test2"> <result name="success" type="redirect">/WEB-INF/index.jsp</result> </action>
- Struts的常量与全局配置
- Struts的常量与全局配置
- Struts 配置(全局,跳转,常量)
- struts的常量配置
- struts全局错误的配置
- struts 2的常量配置
- JavaEE struts的常量配置
- Struts常量的覆盖配置
- struts2的struts.xml常量配置
- struts常量配置
- struts.xml常量配置
- Struts:常量配置
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- struts拦截器配置,以及全局的拦截器配置
- C++全局常量与变量的定义方法
- struts配置全局异常result与全局异常映射mapping以及自定义返回类型
- struts的全局forword
- struts的全局跳转
- java中三种获取class类的方法
- DownloadManager--Android自带的下载工具
- PHP 中 and 与 &&、or 与 || 的 区别
- java程序设计基础(1)
- 布局优化
- Struts的常量与全局配置
- 配置Tomcat时server.xml和content.xml自动还原问题
- Object类及其方法的介绍
- bootstrap模态框html重置后,绑定的click方法失效
- Oracle11g客户端安装及plsql配置
- 深入理解 Promise (上)
- 从零移植uboot 2017 到nuc970(第九天)
- Laravel NotFoundHttpException in RoutesRequests.php line 442
- 一个Linux下C线程池的实现