Struts 2 动作注释 配置动作扩展 全局开关
动作注释
package com.yiibai.user.action;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import com.opensymphony.xwork2.ActionSupport;
@Namespace("/User")
@ResultPath(value="/")
public class ValidateUserAction extends ActionSupport{
@Action(value="Welcome", results={
@Result(name="success",location="pages/welcome_user.jsp")
})
public String execute() {
return SUCCESS;
}
}
配置动作扩展
<struts> <constant name="struts.action.extension" value="html"/>
//<constant name="struts.action.extension" value=""/>
<package name="default" namespace="/" extends="struts-default">
<action name="SayStruts2">
<result>pages/printStruts2.jsp</result>
</action>
</package> </struts> 全局开关
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="false"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.serve.static.browserCache " value="false"/>
<include file="chapter1.xml"/>
</struts>
常用开关的介绍
<constant name="struts.i18n.encoding" value="UTF-8"/>
指定Web应用的默认编码集,相当于调用HttpServletRequest的setCharacterEncoding方法
<constant name="struts.action.extension" value="do"/>
该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts 2处理。 如果用户需要指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开。
<constant name="struts.serve.static.browserCache " value="false"/>
设置浏览器是否缓存静态内容,默认值为true,开发阶段最好false
<constant name="struts.configuration.xml.reload" value="true"/>
当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false,开发阶段最好true
<constant name="struts.devMode" value="true"/>
开发模式下设为true,这样可以打印出更详细的错误信息
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
动态方法调用,可以解决多个请求对应一个Servlet的问题,后面详细讲解,默认为true,关闭则设为false.
Struts 2 动作注释 配置动作扩展 全局开关的更多相关文章
- 在Struts.xml中的result元素指的是:指定动作类的动作方法执行完后的结果视图.
result结果集 上一篇文章主要讲Struts2框架(4)---Action类访问servlet这篇主要讲result结果集 在Struts.xml中的result元素指的是:指定动作类的动作方法执 ...
- Spring+mybatis+struts框架整合的配置具体解释
学了非常久的spring+mybatis+struts.一直都是单个的用他们,或者是两两组合用过,今天总算整合到一起了,配置起来有点麻烦.可是配置完一次之后.就轻松多了,那么框架整合配置具体解释例如以 ...
- Hibernate实现有两种配置,xml配置与注释配置
hibernate实现有两种配置,xml配置与注释配置. (1):xml配置:hibernate.cfg.xml (放到src目录下)和实体配置类:xxx.hbm.xml(与实体为同一目录中) < ...
- struts.xml在Action配置具体解释
在博客上我已经基本上解释struts.xml基本配置.配置过程最为基本的是action的动态配置. 一.Action的创建方法 1)实现Action接口 2)继承ActionSupport类,覆写当中 ...
- hibernate实现有两种配置,xml配置与注释配置。<转>
<注意:在配置时hibernate的下载的版本一定确保正确,因为不同版本导入的jar包可能不一样,所以会导致出现一些错误> hibernate实现有两种配置,xml配置与注释配置. (1) ...
- 配置php扩展memcache
配置php扩展memcache 环境说明: 系统版本 CentOS 6.9 x86_64 软件版本 nginx-1.12.2 php-5.5.38 ...
- Mybatis中SqlMapper配置的扩展与应用(1)
奋斗了好几个晚上调试程序,写了好几篇博客,终于建立起了Mybatis配置的扩展机制.虽然扩展机制是重要的,然而如果没有真正实用的扩展功能,那也至少是不那么鼓舞人心的,这篇博客就来举几个扩展的例子. 这 ...
- 【Cocos2d-X开发学习笔记】第18期:动作类之改变动作对象、函数回调动作以及过程动作的使用
本系列学习教程使用的是cocos2d-x-2.1.4(最新版为3.0alpha0-pre) ,PC开发环境Windows7,C++开发环境VS2010 一.改变动作执行对象 CCTargetedAct ...
- Struts2配置文件复用代码【web.xml、struts.xml、常量配置】
web.xml的分发器代码: <!-- 引入struts核心过滤器 --> <filter> <filter-name>struts2</filter-nam ...
随机推荐
- NFX UNISTACK 介绍
学习.NET Core和ASP.NET Core,偶然搜索到NFX UNISTACK,现翻译一下Readme,工程/原文:https://github.com/aumcode/nfx NFX Serv ...
- Sawgger框架
简介详情:https://blog.csdn.net/sanyaoxu_2/article/details/80555328
- vue http请求 vue-resource使用方法
1.安装vue-resource扩展: npm install vue-resource 2.在main.js中引入 import http from 'vue-resource' 3.使用方法 // ...
- 最大流bfs
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i ...
- 解析Javascript事件冒泡机制(转)
本文转自:http://blog.csdn.net/luanlouis/article/details/23927347 1. 事件 在浏览器客户端应用平台,基本生都是以事件驱动的,即某个事件发生,然 ...
- 完成FileUpload的文件上传功能,且可改按钮样式
FileUpload控件: 更改按钮样式思路: 自己定义一个按钮,设置该按钮的样式,然后将FileUpload控件通过定位定在自己定义的按钮上面,设置z-index,使得控件浮在自己定义的按钮上面,记 ...
- Objective-C Composite Objects
We can create subclass within a class cluster that defines a class that embeds within it an object. ...
- uvm_subscriber——告诉她我们来过
Subscribers are basically listeners of an analysis port. They subscribe to a broadcaster and receive ...
- LINUX提高openfire并发数(网上收集)
谷歌博客地址:http://tsaiquinn.blogspot.com/2014/10/linuxopenfire.html 影响连接数的元素包含三种:1)Linux的系统参数2)进程自身可以创建的 ...
- POJ 1741 Tree (树的分治,树的重心)
题意:给一棵树,n个节点,给定一个数k,求任意满足dist(a,b)<=k的点对的数量. 思路: 这道题的思路比较简单,但是细节很多. 此题可以用分治法,如何分治? (1)如果path(a,b) ...