zoukankan      html  css  js  c++  java
  • 多个XML文件的包含与继承关系

    比如struts.xml文件里包含两个XML文件:global.xml和zhangsan.xml

    struts.xml里:

    1 <?xml version="1.0" encoding="UTF-8" ?>
    2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
    3 <struts>
    4     <include file="global.xml"></include>
    5     <include file="zhangsan.xml"></include>
    6 </struts>    

    global.xml里:(global.xml继承struts-default)

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
     3 <struts>
     4     <package name="global" namespace="/" extends="struts-default">
     5         
     6         <!-- 全局异常的处理 -->
     7         <global-results>
     8             <result name="error">/error.jsp</result>
     9         </global-results>
    10         <global-exception-mappings>
    11             <exception-mapping result="error" exception="java.lang.Exception"></exception-mapping>
    12         </global-exception-mappings>
    13         
    14     </package>
    15 </struts>    

    zhangsan.xml里:(zhangsan.xml继承global)

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
     3 <struts>
     4     <package name="xsl" namespace="/" extends="global">
     5     
     6         <action name="testAction1" class="com.xsl.action.TestAction1">
     7             <!-- 
     8                 type属性不写,默认则为type="dispatcher"
     9                 tyoe="redirect"表示重定向到jsp
    10                 type="chain"表示请求转发至另一个action
    11              -->
    12             <result name="test1" type="dispatcher">/success.jsp</result>
    13             <result name="test2" type="redirect">/success.jsp</result>
    14             <result name="test3" type="chain">testAction2_test1</result>
    15             <result name="test4" type="redirectAction">testAction2_test2</result>
    16         </action>
    17         <!-- struts2.1这个版本要求action在跳转action时,不能写死action的名字 -->
    18         <action name="testAction2_*" class="com.xsl.action.TestAction2" method="{1}">
    19             <result>/success.jsp</result>
    20         </action>
    21 
    22     </package>
    23 </struts>    
  • 相关阅读:
    bootstrutp module 显示隐藏 模态框
    手机app传统邀请码安装与免邀请码安装区别,如何选择呢?
    好用的一些开源系统
    一个搞笑的招聘启事
    java和android及IOS对接RSA加密经验
    mysql大数据表改表结构方案
    android开发中监控android软件网络请求的软件Charles使用入门
    android IOC框架学习记录
    java分布式事务
    十八届三中全会的综合改革方案将涉及哪些内容?(转自知乎)
  • 原文地址:https://www.cnblogs.com/xsl1995/p/6644549.html
Copyright © 2011-2022 走看看