Struts2 include(包含)多个配置文件
struts.xml
<?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> <package name="default" namespace="/" extends="struts-default">
</package> <package name="audit" namespace="/audit" extends="struts-default">
<action name="WelcomeAudit">
<result>pages/welcome_audit.jsp</result>
</action>
</package> <package name="user" namespace="/user" extends="struts-default">
<action name="WelcomeUser">
<result>pages/welcome_user.jsp</result>
</action>
</package> </struts>
在上面的Struts配置文件中,组织所有“用户”和“审核”配置设置在一个文件中,这不是建议的,必须回避。应该打破这种形式,而将struts.xml文件分成更小的模块相关的部分。
- audit-struts.xml – 将所有审计模块设置在这里。
- user-struts.xml – 将所有用户模块设置在这里。
- struts.xml – 默认设置,包含 struts-audit.xml 和 Struts-user.xml 两个文件。
struts-audit.xml
<?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> <package name="audit" namespace="/audit" extends="struts-default">
<action name="WelcomeAudit">
<result>pages/welcome_audit.jsp</result>
</action>
</package> </struts>
struts-user.xml
<?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> <package name="user" namespace="/user" extends="struts-default">
<action name="WelcomeUser">
<result>pages/welcome_user.jsp</result>
</action>
</package> </struts>
struts.xml
<?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> <package name="default" namespace="/" extends="struts-default">
</package> <include file="conf/user-struts.xml"></include>
<include file="conf/audit-struts.xml"></include> </struts>
现在文件夹结构看起来如下:


欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创优秀实例教程
转载请注明:文章转载自:易百教程 [http:/www.yiibai.com]
本文标题:Struts2 include(包含)多个配置文件
本文地址:http://www.yiibai.com/struts_2/struts-2-include-multiple-struts-configuration-files.html
Struts2 include(包含)多个配置文件的更多相关文章
- struts2.0中struts.xml配置文件详解
先来展示一个配置文件 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration ...
- struts2:多模块多配置文件开发
struts2支持多模块多配置文件开发.下面是一个仅包含两个模块的示范程序,包括财务.仓库模块.它们都有一个“caiwu“的Action,在各自的命名空间下:还有一个从财务转向到仓库的Action. ...
- Apache下开启SSI配置使html支持include包含
写页面的同学通常会遇到这样的烦恼,就是页面上的 html 标签越来越多的时候,寻找指定的部分就会很困难,那么能不能像 javascript 一样写在不同的文件中引入呢?答案是有的,apache 能做到 ...
- Apache下开启SSI配置,使html支持include包含
有的时候,我们的页面有公共的导航栏navbar,公共的脚注footer,那么我们就想把这些公共部分独立成一个html文件,在要引用的地方像引用js,css一样,给包含进来. Apache下开启SSI配 ...
- include包含头文件的语句中,双引号和尖括号的区别是什么?
include包含头文件的语句中,双引号和尖括号的区别是什么? #include <> 格式:引用标准库头文件,编译器从标准库目录开始搜索 尖括号表示只在系统默认目录或者括号内的路径查找 ...
- struts2的两个核心配置文件
struts2的两个核心配置文件,即:struts.default.xml和struts.properties A,位置:都在struts2-core-version.jar文件中 B,作用,stru ...
- C++中#include包含头文件带 .h 和不带 .h 的区别
C++中#include包含头文件带 .h 和不带 .h 的区别? 如 #include <iostream> 和 #include <iostream.h> 包含的东西有哪些 ...
- include包含头文件的语句中,双引号和尖括号的区别
include包含头文件的语句中,双引号和尖括号的区别 #include <>格式:引用标准库头文件,编译器从标准库目录开始搜索 #incluce ""格式:引用非 ...
- asp.net使用include包含文件
么?用asp.net使用include包含文件?……有必要吗?使用“用户控件”不是更好吗? 当然,绝大多数情况下,用户控件都能解决问题.但若要在用户控件中需包含其他公用块,即使用用户控件嵌套,老是出问 ...
随机推荐
- selenium grid应用1-多浏览器执行用例
driver =webdriver.Remote(command_executor=’http://127.0.0.1:4444/wd/hub’, desired_capabilities=Desir ...
- Android: 在onCreate()中获得对象尺寸
onCreate() 中 View 尚未绘制完成 很多时候,我们需要在某个界面刚刚加载的时候,执行一些对 View 进行操作的代码,通常我们把这些代码放在 Activity 的 onCreate() ...
- Linux打补丁的一个简单例子
前言 在做开发的过程中难免需要给内核及下载的一些源码打补丁或者说是升级,所以我们学习在Linux下使用diff制作补丁以及如何使用patch打补丁显得尤为重要. diff与patch命令介绍 ...
- entos 7 mailx配置163邮箱发送邮件
配置: .com .com set smtp-auth-user=wcczcl set smtp-auth=login set smtp-use-starttls set ssl-verify=ign ...
- Hadoop案例(七)MapReduce中多表合并
MapReduce中多表合并案例 一.案例需求 订单数据表t_order: id pid amount 1001 01 1 1002 02 2 1003 03 3 订单数据order.txt 商品信息 ...
- C# 6.0 新特性 (四)
原文: 1.http://www.cnblogs.com/BoyceYang/p/3711343.html 2.http://www.cnblogs.com/lhking/p/3660182.html ...
- MySQL表设计:每一种商品有不确定个数的属性
I personally would use a model similar to the following: The product table would be pretty basic, yo ...
- 牛客练习赛9 F - 珂朵莉的约数
题目描述 珂朵莉给你一个长为n的序列,有m次查询 每次查询给两个数l,r 设s为区间[l,r]内所有数的乘积 求s的约数个数mod 1000000007 输入描述: 第一行两个正整数n,m第二行一个长 ...
- Django+Nginx+uwsgi搭建自己的博客(五)
在上一篇博文中,向大家介绍了Users App和Index的前端部分的实现,以及前端与Django的通信部分.至此,我们的博客已经具备一个简单的雏形,可以将其部署在本地的服务器上了.目前较为流行的we ...
- vue-router在IE11中页面不跳转
情景: IE11浏览器中,在进行正常页面跳转操作后(页面A跳转到页面B),点击浏览器的左上角的‘后退’按钮,点击后,可以看到url地址已经发生了变化(url由页面B变为页面A),hash值也已经是上一 ...