struts配置文件l中使用include 标签 引入另外一个在jar中的struts文件
2013-01-08 23:14
483 查看
最近遇到了一个需求:有一个master struts.xml, 该文件中需要引入若该子模块中struts.xml.
但是这些子模块都以jar包的方式放入主模块的classpath中,当然它们的struts.xml也在jar中, 这种情形主模块的struts还能引入吗?
首先问问google,结果是可行, 如下来自struts官方网站:
DOCTYPE. The include files can be placed anywhere on the classpath and should be referred to by that path by the "file" attribute.
开始尝试:
子模块的struts配置文件 名为test-struts.xml, 路径为com/strutsTest/myTest/
1. 在主struts配置文件中使用include标签,并填入全路径, 如下。
2. 在主struts配置文件中使用include标签,只填入文件名, 如下。
3. 在主struts配置文件中使用include标签,只填入文件名 并将子模块中的struts配置文件放入jar的顶级路径中, 即:
主struts配置文件与2相同
可是为什么呢,暂记录,等有时间解释,并期待大牛的答疑。
但是这些子模块都以jar包的方式放入主模块的classpath中,当然它们的struts.xml也在jar中, 这种情形主模块的struts还能引入吗?
首先问问google,结果是可行, 如下来自struts官方网站:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="Home.xml"/> <include file="Hello.xml"/> <include file="Simple.xml"/> <include file="/util/POJO.xml"/> <include file="/com/initech/admin/admin-struts.xml"/> </struts>Each included file must be in the same format as struts.xml, including the
DOCTYPE. The include files can be placed anywhere on the classpath and should be referred to by that path by the "file" attribute.
开始尝试:
子模块的struts配置文件 名为test-struts.xml, 路径为com/strutsTest/myTest/
1. 在主struts配置文件中使用include标签,并填入全路径, 如下。
<?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> <include file="struts-default.xml" /> <include file="com/strutsTest/myTest/test-struts.xml" /> </struts>结果:扑街
2. 在主struts配置文件中使用include标签,只填入文件名, 如下。
<?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> <include file="struts-default.xml" /> <include file="test-struts.xml" /> </struts>结果:扑街
3. 在主struts配置文件中使用include标签,只填入文件名 并将子模块中的struts配置文件放入jar的顶级路径中, 即:
childModule.jar -com --strutsTest --..... test-struts.xml
主struts配置文件与2相同
<?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> <include file="struts-default.xml" /> <include file="test-struts.xml" /> </struts>结果: 成功!
可是为什么呢,暂记录,等有时间解释,并期待大牛的答疑。
相关文章推荐
- struts配置文件l中使用include 标签 引入另外一个在jar中的struts文件
- jQuery使用load()方法载入另外一个网页文件内的指定标签内容到div标签的方法
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- struts2.0 读取配置文件 在直接使用标签读取
- validation.xml验证文件的配置 struts标签使用举例--logic篇
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- JSP标签 使用引入jstl.jar 使用 bootstrap需要引入的文件(在线文件)
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- 【VS开发】利用VS2015的工程文件来复制另外一个工程的配置的使用说明
- validation.xml验证文件的配置 常用struts标签使用举例--bean篇
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- JDBC的第一个版本,不使用配置文件。使用jar文件一个
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- 布局文件的引入<include>标签的使用
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- 【转】static和extern的区别;当使用另外一个文件中的变量、类、方法时,什么时候改用extern声明,什么时候该include?
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件