您的位置:首页 > 编程语言 > Java开发

SSH整合_struts.xml 模板

2014-09-23 00:09 351 查看
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.custom.i18n.resources" value="msg" />

<package name="default" namespace="/" extends="json-default">
<!--定义自己的拦截器  -->
<interceptors>
<!-- 登录检验拦截器 -->
<interceptor name="loginInterceptor" class="cn.itcast.invoice.util.interceptor.LoginInterceptor"/>
<interceptor name="exceptionInterceptor" class="cn.itcast.invoice.util.interceptor.ExceptionInterceptor"/>
<interceptor name="authInterceptor" class="cn.itcast.invoice.util.interceptor.AuthInterceptor"/>
<!-- 定义项目中的使用的拦截器栈,原始的拦截器还要使用,追加我们自定义的拦截器 -->
<interceptor-stack name="systemStack">
<!--
自定义的拦截器配置在系统拦截器上方,
要注意这几个自定义的拦截器之间的顺序也是有讲究的.
异常拦截器 exceptionInterceptor在最外边
权限拦截器authInterceptor要在登录拦截器loginInterceptor的里面,
如果两者顺序颠倒,永远登录不成功.
最内层追加默认的拦截器.
-->
<interceptor-ref name="exceptionInterceptor"/>
<interceptor-ref name="loginInterceptor"/>
<interceptor-ref name="authInterceptor"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>

<!-- 开启自定义拦截器 -->
<default-interceptor-ref name="systemStack"/>
<!-- 全局 -->
<!-- 配置全局result给拦截器使用 -->
<!-- 在xml中使用EL表达式. -->
<global-results>
<result name="loginFail" type="redirect">index.jsp</result>
<result name="loginSuccess">/WEB-INF/jsps/main.jsp</result>
<result name="list">/WEB-INF/jsps/${actionName}/list.jsp</result>
<result name="toList" type="redirectAction">${actionName}_list</result>
<result name="input">/WEB-INF/jsps/${actionName}/input.jsp</result>
<result name="error">/WEB-INF/jsps/error.jsp</result>
</global-results>

<!-- 部门 -->
<action name="dep_*" class="depAction" method="{1}">
<result name="list">/WEB-INF/jsps/dep/list.jsp</result>
<result name="input">/WEB-INF/jsps/dep/input.jsp</result>
</action>

<!--员工  -->
<!--这个地方用到了strtus和spring的整合.在spring的关于emp的配置文件中已经配置了bean"empAction",而且这个bean中
也有class属性和name属性.就可以找到对应的EmpAction类,在这个struts.xml中的配置文件中就用spring配置文件中的类"伪类!!!" -->
<action name="emp_*" class="empAction" method="{1}">
<!--
<result name="list">/WEB-INF/jsps/emp/list.jsp</result>
这个地方用通用的配置.emp模块的result name ="list" 和dep模块的结果路径就只有emp和dep不同.
-->

<!-- 登陆成功 -->
<!-- 跳转到主页 -->
<!-- <result name="loginSuccess">/WEB-INF/jsps/main.jsp</result> -->
<!-- 登陆失败 -->
<!-- 跳转回登陆页 -->
<!-- 暂定 -->
<!-- <result name="loginFail">/WEB-INF/jsps/login.jsp</result>    -->
</action>

<!-- 角色 -->
<action name="role_*" class="roleAction" method="{1}">
</action>

<!-- 资源 -->
<action name="res_*" class="resAction" method="{1}">
</action>

<!-- 菜单 -->
<action name="menu_*" class="menuAction" method="{1}">
</action>

<!-- 供应商 -->
<action name="supplier_*" class="supplierAction" method="{1}">
</action>

<!-- 商品类别 -->
<action name="goodsType_*" class="goodsTypeAction" method="{1}">
<result name="toList" type="redirectAction">goodsType_list</result>
<!-- 设置当前结果集为转换数据格式为json -->
<!-- 由于该格式是由插件中提供的struts-json-plugin.jar,需要注意使用规则 -->
<!-- 修改当前action所在的package的包继承自json-default -->
<result name="ajaxGetAllBySupplierUuid" type="json">
<!-- 设置要返回的数据 -->
<!-- 设置返回的数据在哪里? -->
<!-- 设置数据的来源位置在哪里,当前设置为action类中 -->
<!-- !!!!!那些数据参与到action中的数据返回:只有get开头的才参与返回!!!!!! -->
<!-- 在GoodsTypeAction.java中有提供public List<GoodsTypeModel> getGtmList(){}方法 -->
<!-- 这个地方的几乎都是这么写,name="root"中间对的是action,也可以是一个对象,单是有局限性 -->
<param name="root" >action</param>
<!-- 返回的数据量太大(这个地方返回的是一个gtmList集合),需要删除一部分,只要我们使用的一部分,这就用到了数据过滤 -->
<!-- 设置需要的数据 -->
<param name ="includeProperties">
<!-- 需要哪些数据? -->
<!-- 该格式是正则表达式 -->
<!-- 属性与属性值之间使用,用逗号","分隔 -->
<!-- 集合对象中包含的对象的uuid属性 -->
<!-- 一定要注意这个地方的书写格式,要在什么地方加上"\"否则页面会无法得到你想要的效果.
当时我这里写错了,jsp中的就无法获得的gtmList的值.
-->
gtmList\[\d+\]\.uuid,
<!-- 集合对象中包含的对象的name属性 -->
gtmList\[\d+\]\.name
</param>
<!-- 这里也可以设置你不需要的数据进行过滤,得到你需要的数据 -->
<!--
这种方式反而不常用,因为,你过滤掉不需要的,但是这里看不出来你需要的,不够清晰明确
<param name="excludeProperties">
gtmList\[\d+\]\.sm
</param>
-->
</result>
</action>

<!-- 商品 -->
<action name="goods_*" class="goodsAction" method="{1}">
</action>

<!--
配置action要求指定的类必须是ActionSupport类型的对象
可以自定义,也可以使用系统类来完成
如果使用系统类完成,可以使用默认配置,省略class属性.
-->
<!--
<action name="login" class="com.opensymphony.xwork2.ActionSupport">
<result>/WEB-INF/jsps/login.jsp</result>
</action>
-->

<!-- 使用通配的格式来完成非业务action的跳转功能,这个地方就是指的是页面之间的跳转 -->
<!-- 这个action的配置中没有class的属性配置,只有name -->
<action name="pages_*" >
<!-- result标签中也没有name的属性配置 -->
<result>/WEB-INF/jsps/{1}.jsp</result>
</action>

<!-- 在改密码的时候用到了这种配置 -->
<action name="page_*_*" >
<!-- result标签中也没有name的属性配置 -->
<result>/WEB-INF/jsps/{1}/{2}.jsp</result>
</action>

<!-- 不使用上面的通配的方式就要向下边这样一个个写 -->
<!--
<action name="login">
<result>/WEB-INF/jsps/login.jsp</result>
</action>

<action name="context">
<result>/WEB-INF/jsps/context.jsp</result>
</action>
-->

<!--订单 -->
<action name="order_*" class="orderAction" method="{1}">
<!-- 订单中的"申请" -->
<!-- 这个地方相比以往多了一层目录结构(buy),不能再用通用的了. -->
<result name="list">/WEB-INF/jsps/order/buy/list.jsp</result>
<result name="input">/WEB-INF/jsps/order/buy/input.jsp</result>
<result name="buyDetail">/WEB-INF/jsps/order/buy/buyDetail.jsp</result>

<!-- 订单中的"审批" -->
<result name="checkList">/WEB-INF/jsps/order/buy/checkList.jsp</result>
<result name="buyCheckDetail">/WEB-INF/jsps/order/buy/buyCheckDetail.jsp</result>
<result name="toCheckList" type="redirectAction">order_checkList</result>

<!-- 入库 -->
<result name="inList">/WEB-INF/jsps/store/in/list.jsp</result>
<result name="inDetail">/WEB-INF/jsps/store/in/inDetail.jsp</result>

<!-- Ajax提交对应的reslut结果 -->
<result name="ajaxGetGtmAndGm" type="json">
<param name="root">action</param>
<param name="includeProperties">
gtmList\[\d+\]\.uuid,
gtmList\[\d+\]\.name,
gmList\[\d+\]\.uuid,
gmList\[\d+\]\.name,
<!-- 对象的属性如何映射? -->
<!-- 格式:对象名.属性名 -->
gm\.inPriceView
</param>
</result>

<result name="ajaxGetGm" type="json">
<param name="root">action</param>
<param name="includeProperties">
gmList\[\d+\]\.uuid,
gmList\[\d+\]\.name,
gm\.inPriceView
</param>
</result>

<result name="ajaxGetOne" type="json">
<!-- root参数设置的是数据的来源 -->
<!-- 如果设置为一个get方法对应的名称,则数据直接来源与对应的变量 -->
<param name="root">gm</param>
<param name="includeProperties">
inPriceView,
outPriceView
</param>
</result>
<!--
<result name="******" type="json">
root参数设置的是数据的来源
如果设置为一个get方法对应的名称,则数据直接来源与对应的变量
如果是集合或数组对象,那么省略集合名称
外部得到的json数据,默认为[{},{},{}]
<param name="root">gmList</param>
<param name="includeProperties">
\[\d+\]\.uuid
</param>
</result>
-->
</action>

<!-- 订单明细 -->
<action name="orderDetail_*" class="orderDetailAction" method="{1}">
<result name="ajaxGetNumAndSurplusByOdmUuid" type="json">
<!--在action中获得的是一个OrderDetailModel对象 om = orderDetailEbi.get(om.getUuid()); -->
<!-- 在这个对象中获取想要的surplus和num数据 -->
<param name="root">om</param>
<!-- 上面的root为action的也可以用对象取. -->
<param name="includeProperties">
num,
surplus
</param>
</result>
</action>

<!-- 商品运输任务 -->
<action name="transport_*" class="orderAction" method="{1}">
<result name="list">/WEB-INF/jsps/order/transport/list.jsp</result>
<result name="toTransportList" type="redirectAction">transport_transportList</result>
<result name="assignTask">/WEB-INF/jsps/order/transport/assignTask.jsp</result>

<result name="tasks">/WEB-INF/jsps/order/transport/tasks.jsp</result>
<result name="toTasks" type="redirectAction">transport_tasks</result>
<result name="taskDetail">/WEB-INF/jsps/order/transport/taskDetail.jsp</result>
</action>

<!-- 仓库 -->
<action name="store_*" class="storeAction" method="{1}">
</action>

<!--报表 -->
<action name="bill_*" class="billAction" method="{1}">
<result name="getExcelBill" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">downloadStream</param>
<param name="contentDisposition">attachment;filename=${xlsName}</param>
</result>
<result name="ajaxGetGoodsDetail" type="json">
<param name="root">odmList</param>
<param name="includeProperties">
\[\d+\]\.num,
\[\d+\]\.priceView,
\[\d+\]\.totalPriceView,
\[\d+\]\.om\.createTimeView,
\[\d+\]\.om\.orderNum
</param>
</result>
</action>
</package>
</struts>


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: