struts2.0中struts.xml配置文件详解
关键字: Struts
Java代码
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd" >
<struts>
<!-- include节点是struts2中组件化的方式 可以将每个功能模块独立到一个xml配置文件中 然后用include节点引用 -->
<include file="struts-default.xml"></include>
<!-- package提供了将多个Action组织为一个模块的方式
package的名字必须是唯一的 package可以扩展 当一个package扩展自
另一个package时该package会在本身配置的基础上加入扩展的package
的配置 父package必须在子package前配置
name:package名称
extends:继承的父package名称
abstract:设置package的属性为抽象的 抽象的package不能定义action 值true:false
namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action
-->
<package name="com.kay.struts2" extends="struts-default" namespace="/test">
<interceptors>
<!-- 定义拦截器
name:拦截器名称
class:拦截器类路径
-->
<interceptor name="timer" class="com.kay.timer"></interceptor>
<interceptor name="logger" class="com.kay.logger"></interceptor>
<!-- 定义拦截器栈 -->
<interceptor-stack name="mystack">
<interceptor-ref name="timer"></interceptor-ref>
<interceptor-ref name="logger"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- 定义默认的拦截器 每个Action都会自动引用
如果Action中引用了其它的拦截器 默认的拦截器将无效 -->
<default-interceptor-ref name="mystack"></default-interceptor-ref>
<!-- 全局results配置 -->
<global-results>
<result name="input">/error.jsp</result>
</global-results>
<!-- Action配置 一个Action可以被多次映射(只要action配置中的name不同)
name:action名称
class: 对应的类的路径
method: 调用Action中的方法名
-->
<action name="hello" class="com.kay.struts2.Action.LoginAction">
<!-- 引用拦截器
name:拦截器名称或拦截器栈名称
-->
<interceptor-ref name="timer"></interceptor-ref>
<!-- 节点配置
name : result名称 和Action中返回的值相同
type : result类型 不写则选用superpackage的type struts-default.xml中的默认为dispatcher
-->
<result name="success" type="dispatcher">/talk.jsp</result>
<!-- 参数设置
name:对应Action中的get/set方法
-->
<param name="url">http://www.sina.com</param>
</action>
</package>
</struts>
分享到:
相关推荐
绝对的好东西 struts2.0中struts.xml配置文件详解
struts.xml配置文件详解struts.xml配置文件详解struts.xml配置文件详解
struts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.doc
struts-config.xml配置文件详解
struts1 web.xml struts1配置
Struts-config.xml配置详解,介绍Struts-config中8个元素配置方法。
Struts-config.xml 配置详解.doc Struts-config.xml 配置详解.doc
这个strut-config配置详解是韩顺平老师指定的 很多同学都看过韩老师的视频或者上过韩老师的课程吧
韩顺平视频配套struts-config.xml配置详解.txt
NULL 博文链接:https://wellfrog.iteye.com/blog/612014
struts自动加载的一个配置文件列表 struts.configuration.xml.reload Whether to reload the XML configuration or not 是否加载xml配置(true,false) struts.continuations.package The package containing ...
SSH之Struts1之struts-config.xml常用配置详解(3-21-2008)
struts.xml详解.docstruts.xml详解.docstruts.xml详解.doc
struts.xml文件详解示例代码,可以参照http://blog.csdn.net/jiajia333666/article/details/47979919 阅读。
配置 struts-config.xml 元素 属性的详解!转载来的,,看着很好!》希望对大家有用!
Struts应用采用两个基于XML的配置文件来配置,分别是web.xml和struts-cofig.xml文件.web.xml文件是配置所有web应用的,而struts-config.xml文件是struts专用的配置文件。事实上也是可以根据需要给这个配置文件起其他...
拦截器 验证器 struts.xml配置文档详解 本人在该实例中遇到的最大问题及解决方案: "struts2.0做文件上传关于所加载的错误包造成的问题心得" 1:commons-io-1.4.jar 做上传时,如果用的该包是1.0的就经常出经上传不...
struts-config.xml 文件详解 以下是一份完整的struts-config.xml文件,配置元素的说明详见注释.