01-struts2配置详解
1 struts.xml配置详解
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- i18n:国际化. 解决post提交乱码 ,get提交乱码原来怎么解决还是怎么解决-->
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
<!-- 指定访问action时的后缀名
http://localhost:8080/struts2_day01/hello/HelloAction.do
-->
<constant name="struts.action.extension" value="action,,"></constant>
<!-- 指定struts2是否以开发模式运行
1.热加载主配置.(不需要重启即可生效)
2.提供更多错误信息输出,方便开发时的调试
-->
<constant name="struts.devMode" value="true"></constant> <!-- package:将Action配置封装.就是可以在Package中配置很多action.
name属性: 给包起个名字,起到标识作用.随便起.不能与其他包名重复.
namespace属性:给action的访问路径中定义一个命名空间,可以直接就一个/
extends属性: 继承一个 指定包
abstract属性:包是否为抽象的; 标识性属性.标识该包不能独立运行.专门被继承
-->
<package name="hello" namespace="/" extends="struts-default">
<!-- action元素:配置action类
name属性: 决定了Action访问资源名.
class属性: action的完整类名
method属性: 指定调用Action中的哪个方法来处理请求
-->
<action name="HelloAction" class="www.test.a_hello.HelloAction" method="hello">
<!-- result元素:结果配置
name属性: 标识结果处理的名称.与action方法的返回值对应.
type属性: 指定调用哪一个result类来处理结果,默认使用转发.
标签体:填写页面的相对路径
-->
<result name="success" type="dispatcher">/hello.jsp</result>
</action>
</package>
<!-- 引入其他struts配置文件 -->
<include file="www/test/b_dynamic/struts.xml"></include>
<include file="www/test/c_default/struts.xml"></include>
</struts>
2 struts2配置进阶-动态方法调用
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- 配置动态方法调用是否开启常量
默认是关闭的,需要开启
-->
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="dynamic" namespace="/dynamic" extends="struts-default">
<action name="Demo1Action" class="www.test.b_dynamic.Demo1Action">
<result name="success">/hello.jsp</result>
</action>
</package> --> <package name="dynamic" namespace="/" extends="struts-default">
<action name="Demo1Action_*" class="www.test.b_dynamic.Demo1Action" method="{1}">
<result name="success" type="dispatcher">/hello.jsp</result>
</action>
</package>
</struts>
3 struts2 配置进阶-默认值
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default"> <!-- 找不到包下的action,会使用Demo2Action作为默认action处理请求 -->
<default-action-ref name="Demo2Action"></default-action-ref> <!-- method属性:默认值execute -->
<!-- result的name属性:默认值success -->
<!-- result的type属性:默认值dispatcher 转发 -->
<!-- class属性:默认值 com.opensymphony.xwork2.ActionSupport -->
<action name="Demo2Action">
<result>/hello.jsp</result>
</action>
</package>
</struts>
01-struts2配置详解的更多相关文章
- struts2系列(三):struts2配置详解
原文链接:http://www.cnblogs.com/fmricky/archive/2010/05/20/1740479.html 1.<include> 利用include标签,可以 ...
- struts2配置详解
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
- Struts2 配置详解
1. web.xml 此文件的配置可以参看struts2的示例文档 <filter> <filter-name>struts2</filter-name> < ...
- Struts2配置详解_配置Action
Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实现 ...
- 第三章 Struts2配置详解
3.1 Struts2执行过程 1.获取Struts2资源 2.在应用程序中导入Struts2的类库 3.在web.xml中配置StrutsPrepareAndExecuteFilt ...
- Struts2学习笔记二 配置详解
Struts2执行流程 1.简单执行流程,如下所示: 在浏览器输入请求地址,首先会被过滤器处理,然后查找主配置文件,然后根据地址栏中输入的/hello去每个package中查找为/hello的name ...
- struts2基本配置详解2
接上篇struts2基本配置详解,还有一些配置没有讲到,下面将继续. struts.xml <package name="com.amos.web.action" names ...
- Struts2学习笔记(二)——配置详解
1.Struts2配置文件加载顺序: default.properties(默认常量配置) struts-default.xml(默认配置文件,主要配置bean和拦截器) struts-plugin. ...
- Spark log4j日志配置详解(转载)
一.spark job日志介绍 spark中提供了log4j的方式记录日志.可以在$SPARK_HOME/conf/下,将 log4j.properties.template 文件copy为 l ...
- log4j.properties配置详解与实例
log4j.properties配置详解与实例 第一步:加入log4j-1.x.x.jar到lib下. 第二步:在工程的src下下建立log4j.properties.内容如下: #OFF,syste ...
随机推荐
- 15分XX秒后订单自动关闭(倒计时)
//订单记录 function get_order(){ //请求订单ajax方法 XX.send_api("method",{data},function(){ var date ...
- orcl 对table的一些操作
删除 table:drop table 表名: 恢复删除 : flashback table 表名 to before drop: 清空table : truncate table 表名; 恢复清空: ...
- C#winform拖动无边框窗体
private bool isMouseLeftKeyDown = false; private Point mousePointToClient = new Point();//相对于本窗体鼠标位置 ...
- 使用VS Code编写Markdown文件
VS Code默认支持Markdown文件文件格式,这里介绍两个比较实用的功能,后续有新发现,可以持续更新. 实时预览 顾名思义,实时编辑,实时预览解析效果. 在VS Code扩展中搜索"M ...
- SQLServer备份恢复助手(太强大了!)
下载地址: http://download.csdn.net/detail/gguozhenqian/8105779
- 「CF140C」 New Year Snowmen
题目链接 戳这 贪心+优先队列,只要每次将数量前三大的半径拿出来就好了,用优先队列维护一下 #include<bits/stdc++.h> #define rg register #def ...
- LoadRunner--获取请求的返回结果函数
注:内容来自网络 Action(){ web_set_max_html_param_len("262144"); // 默认最大长度为256 web_reg_save_param( ...
- Centos7.5的定制化安装
一.前言 关于定制化centos7.5的镜像真的是历经波折,前前后后.来来回回尝试了不少于20次,上网找了各种关于定制7系统的方法,都没有成功... 但最终功夫不负有心人终于解决了,O(∩_∩)O哈哈 ...
- CHNetRequest网络请求
Paste JSON as Code • quicktype 软件的使用 iOS开发:官方自带的JSON使用 JSON 数据解析 XML 数据解析 Plist 数据解析 NetRequest 网络数据 ...
- 第十篇 requests模块
1.安装requests 要安装requests,在终端中输入以下命令即可安装: pip3 install requests 2.发送请求 使用requests发送请求首先需要导入requests模块 ...