//定义了xml文件的版本和编码
<?xml version="1.0" encoding="UTF-8"?>
//配置文件中的元素必须按照下述doc指令中的dtd文档定义顺序书写,本例即遵从了dtd定义顺序,struct-config是整个xml的根元素,其他元素必须包含在内。
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
//这个标签是用来配置数据源的,具体的配置方法我们可以在网上找一个实例进行查看,可以通过<set-property>设置driverClass、url、user、password等属性。
<data-sources />
//子元素form-beans用来配置绑定到Action的各个FormBean的实例。每个FormBean实例用form-bans的子元素form-bean来定义。form-bean又分普通的FormBan和动态FormBean。参考该网址:http://www.cnblogs.com/panjun-Donet/articles/1181811.html
<!-- 注册ActionForm -->
<form-beans>
<form-bean name="userForm" type="com.lyq.struts.form.UserForm"/>
<form-bean name="medForm" type="com.lyq.struts.form.MedicineForm"/>
<form-bean name="categoryForm" type="com.lyq.struts.form.CategoryForm"/>
<form-bean name="sellDetailForm" type="com.lyq.struts.form.SellDetailForm"/>
</form-beans>
//global-forwards用于配置全局转发,struts首先会在<action-mappings>元素中找对应的<forward>,若找不到,则到全局转发配置中找。它包含0个或多个<forward/>元素,格式如///下所示:<forward name="唯一的名称" path="指向资源的相对路径"/
<global-exceptions />
  <!-- 全局跳转 -->
<global-forwards>
<forward name="login" path="/login.jsp" redirect="true"/>
<forward name="buy" path="/sell/sell.do?command=add"/>
<forward name="error" path="/error.jsp"/>
<forward name="manage" path="/manager.jsp"/>
</global-forwards>
// 该元素用于将Action元素定义到ActionServlet类中,它含有0到多个<action/>元素,其格式如下:
// scope:指定ActionForm Bean的作用域(session和request),缺省为session。(可选);
<action-mappings>
<!-- 用户登录 -->
<action path="/login"
type="com.lyq.struts.action.LoginAction"
name="userForm"
scope="request">

<forward name="loginFail" path="/login.jsp"/>
</action>
<!-- 语言选择 -->
<action path="/language"
type="com.lyq.struts.action.LanguageAction"
scope="request" />
<!-- 类别 -->
<action path="/baseData/category"
type="com.lyq.struts.action.CategoryAction"
name="categoryForm"
scope="request"
parameter="command">
<forward name="paging" path="/baseData/category.do?command=paging" />
<forward name="findAllSuccess" path="/baseData/category_list.jsp" />
<forward name="edit" path="/baseData/category_add.jsp" />
<forward name="categoryGraph" path="/baseData/category_graph.jsp" />
</action>
<!-- 药品 -->
<action path="/baseData/med"
type="com.lyq.struts.action.MedicineAction"
name="medForm"
scope="request"
parameter="command">
<forward name="addSuccess" path="/baseData/med.do?command=paging" />
<forward name="findAllSuccess" path="/baseData/med_list.jsp" />
<forward name="view" path="/baseData/med_view.jsp" />
<forward name="add" path="/baseData/med_add.jsp" />
<forward name="medUpdate" path="/baseData/med_update.jsp" />
<forward name="medSave" path="/baseData/med_save.jsp" />
<forward name="canSellMeds" path="/baseData/med_sell.jsp" />
</action>
<!-- 删除药品信息 -->
<action path="/baseData/deleteMedicineAction"
type="com.lyq.struts.action.DeleteMedicineAction"
parameter="command">
<forward name="findAllSuccess" path="/baseData/med.do?command=paging" />
</action>
<!-- 药品需求 -->
<action path="/require/require"
type="com.lyq.struts.action.RequireAction"
name="medForm"
scope="request"
parameter="command">
<forward name="addSuccess" path="/require/require.do?command=paging" />
<forward name="findAllSuccess" path="/require/req_list.jsp" />
<forward name="medUpdate" path="/require/req_update.jsp" />
<forward name="medSave" path="/require/req_save.jsp" />
<forward name="add" path="/require/req_add.jsp" />
<forward name="view" path="/baseData/med_view.jsp" />
</action>
<!-- 删除药品需求信息 -->
<action path="/require/deleteReqMedAction"
type="com.lyq.struts.action.DeleteReqMedAction"
parameter="command">
<forward name="findAllSuccess" path="/require/require.do?command=paging" />
</action>
<!-- 销售 -->
<action path="/sell/sell"
type="com.lyq.struts.action.SellAction"
name="sellDetailForm"
scope="request"
parameter="command">
<forward name="add" path="/sell/sell_add.jsp" />
<forward name="order" path="/sell/sell_order.jsp" />
<forward name="paging" path="/sell/sell.do?command=paging" />
<forward name="findAllSuccess" path="/sell/sell_list.jsp" />
<forward name="sequence" path="/sell/sell_seq_list.jsp" />
</action>
<!-- 系统管理 -->
<action path="/system/system"
type="com.lyq.struts.action.SystemAction"
name="userForm"
scope="request"
parameter="command">
<forward name="userFind" path="/system/system.do?command=userFind" />
<forward name="findAllSuccess" path="/system/user_list.jsp"/>
<forward name="userEdit" path="/system/user_add.jsp"/>
</action>
</action-mappings>
//该元素用来定义资源文件,parameter="给定资源文件的全名"
/*

<message-resources parameter="给定资源文件的全名" classname="定义处理消息资源的类名的全名"  factory="定义MessageResourcesFactory类的全名"  key="定义绑定在这个资源包中的ServletContext的属性主键"  null=" 如果为true,则找不到消息key时,则返回null "/>

*/

<message-resources parameter="com.lyq.struts.MessageResources" />
</struts-config>

plug-in

该元素用于定义插件,可定义0到多个插件元素,最常见的plug-in为Struts的验证的插件,配置举例如下:

Eg1. Struts的验证的plug-in:

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">

<set-property property="pathnames"

value="/WEB-INF/validator-rules.xml, /WEB-INF/manager/validation.xml" />

<set-property property="stopOnFirstError" value="false" />

</plug-in>

Eg2. Spring提供的载入插件配置:

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

<set-property property="contextConfigLocation"

value="/WEB-INF/applicationContext.xml, /WEB-INF/action-servlet.xml"/>

</plug-in>

struct-config.xml配置文件的解析的更多相关文章

  1. Cordova V3.0.0中config.xml配置文件的iOS Configuration

    http://www.cnblogs.com/lovecode/articles/3305655.html   轉載這個 <preference> 关于这个标签的可用设置有: Disall ...

  2. Spring框架[一]——spring概念和ioc入门(ioc操作xml配置文件)

    Spring概念 spring是开源的轻量级框架(即不需要依赖其他东西,可用直接使用) spring核心主要两部分 aop:面向切面编程,扩展功能不是修改源代码来实现: ioc:控制反转,比如:有一个 ...

  3. mybatis源码-解析配置文件(一)之XML的DOM解析方式

    目录 简介 Java 中 XML 文件解析 解析方式 DOM 解析 XML 新建 XML 文件 DOM 操作相关类 Java 读取 XML 文件 一起学 mybatis @ 简介 在之前的文章< ...

  4. dom4j解析xml配置文件

    通过dom4j来对xml配置文件的增删查改: 利用@Test注解来对单个方法进行测试: import java.io.FileOutputStream; import java.io.OutputSt ...

  5. 刨析Maven(对pom.xml配置文件常用标签的解析)

    昨天在阿里云看到了一句话,"当你Learning和Trying之后,如果能尽量把Teaching也做好,会促进我们思考".共勉! 这是关于Maven的第三篇博客,这次我们深入了解p ...

  6. Mybatis 源码分析--Configuration.xml配置文件加载到内存

    (补充知识点: 1 byte(字节)=8 bit(位) 通常一个标准英文字母占一个字节位置,一个标准汉字占两个字节位置:字符的例子有:字母.数字系统或标点符号) 1.创建SqlSessionFacto ...

  7. 转-springAOP基于XML配置文件方式

    springAOP基于XML配置文件方式 时间 2014-03-28 20:11:12  CSDN博客 原文  http://blog.csdn.net/yantingmei/article/deta ...

  8. 用java操作XML文件(DOM解析方式)

    XML 可扩展标记语言(Extensible Markup Language),是独立于软件和硬件的传输工具. XML的作用: (1)用作配置文件 (2)简化数据共享 (3)简化数据传输 XML DO ...

  9. DOM4J 读取XML配置文件进行数据库连接

        介绍介绍DOM4J.    据说是非常优秀非常优秀的Java XML  API(Dom4j is an easy to use, open source library for working ...

随机推荐

  1. 被人遗忘的MAX_FILE_SIZE文件上传限制大小参数

    在文件上传中,我们经常会要求显 示用户上传文件大小,超过上传限制的文件就会不允许用户上传.虽然我们可以用程序去判断上传文件是否超过限制,但是其实我们的PHP程序是无法判断用户本 地文件大小的.所以等到 ...

  2. python中set类型总结

    set的创建无非有两种方式: 一 直接使用{}创建新的set并初始化 例如: set1 = {1,2,3,"good news",(1,2,3)} #声明的时候可以包含元组,但不能 ...

  3. poj3189二分图多重匹配

    题意:有一些牛和牛棚(有容量),每头牛对牛棚有喜好程度,要求每头牛都有一个棚子的情况下,找最小的喜好程度之差 题解:题意是真的恶心,wa了好久才发现没读懂,一直以为输入 的是排名,其实是牛棚标号,从1 ...

  4. npm package管理

    每个项目都包含一个package.json文件用来管理项目依赖的包以及项目相关信息. 其中比较总要的就是dependencies和devDependencies两项,分别指定了项目运行所依赖的模块.项 ...

  5. UVALive - 4270 Discrete Square Roots (扩展欧几里得)

    给出一组正整数$x,n,r$,使得$r^2\equiv x(mod\: n)$,求出所有满足该等式的$r$. 假设有另一个解$r'$满足条件,则有$r^2-r'^2=kn$ 因式分解,得$(r+r') ...

  6. BZOJ5334: [Tjoi2018]数学计算

    BZOJ5334: [Tjoi2018]数学计算 https://lydsy.com/JudgeOnline/problem.php?id=5334 分析: 线段树按时间分治即可. 代码: #incl ...

  7. 隐藏select中的“请选择”项

    <select> <option value="" style="display: none">请选择</option> & ...

  8. 服务器上传大小限制 --- 来自 FastAdmin 项目开发的引发的问题 (TODO)

    服务器上传大小限制 --- 来自 FastAdmin 项目开发的引发的问题 服务器上传有几个地方修改. FastAdmin 的配置. php.ini 的配置. NGINX 的配置.

  9. Mac上制作Centos7系统U盘安装盘

    Centos7 下载地址: http://101.110.118.47/isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD- ...

  10. HDU1576(扩展欧几里得)

    A/B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...