struts.xml 为Struts 2的核心配置文件。struts.xml文件主要负责管理应用中的Action映射,以及该Action包含的Result定义等。
struts.xml中主要配置Struts项目的一些全局的属性,用户请求和响应Action之间的对应关系,以及配置Action中可能用到的参数,以及处理结果的返回页面。还包括各种拦截器的配置等。
例子:
<?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" extends="strongmvc-default">
<!-- 基于jasperreport报表结果,jfreechart图表结果,增加jasper,chart -->
<result-types>
<result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult"/>
<result-type name="chart" class="org.apache.struts2.dispatcher.ChartResult">
<param name="height">150</param>
<param name="width">200</param>
</result-type>
</result-types>
<!-- 基于paramsPrepareParamsStack,增加store interceptor --><!--
<interceptors>
<interceptor-stack name="DemoStack">
<interceptor-ref name="StrongMVCStack" />
<interceptor-ref name="defaultStack" />
<interceptor-ref name="exceptionInterceptor">
<param name="bundlePath">resource.Message</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
-->
<interceptors>
<interceptor-stack name="DemoStack">
<!--<interceptor-ref name="StrongMVCStack" />
<interceptor-ref name="defaultStack" />-->
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<interceptor-ref name="paramsPrepareParamsStack" />
<interceptor-ref name="exceptionInterceptor">
<param name="bundlePath">com.strongit.uums.resource.Message</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="DemoStack" />
<action name="basePrivil1" class="com.strongit.uums.privilmanage.BasePrivilAction">
<!-- Chain to another namespace -->
<result name="move" type="chain">
<param name="actionName">basePrivil</param>
<param name="method">priviltree</param>
</result>
</action>
<action name="orgmanage1" class="com.strongit.uums.organisemanage.OrgmanageAction">
<!-- Chain to another namespace -->
<result name="move" type="chain">
<param name="actionName">orgmanage</param>
<param name="method">tree</param>
</result>
</action>
<action name="baseGroup1" class="com.strongit.uums.usergroup.BaseGroupAction">
<!-- Chain to another namespace -->
<result name="move" type="chain">
<param name="actionName">baseGroup</param>
<param name="method">groupTree</param>
</result>
</action>
<action name="report_*" class="com.strongit.workflow.workflowreport.WorkFlowReportAction" method="report">
<result name="report" type="jasper">
<param name="location">
/WEB-INF/jsp/workflowreport/jasperfile/jasper_template.jasper
</param>
<param name="dataSource">processTypeDataList</param>
<param name="format">{1}</param>
</result>
<result name="notdate" type="jasper">
<param name="location">
/WEB-INF/jsp/workflowreport/jasperfile/jasper_notdate.jasper
</param>
<param name="dataSource">processTypeDataList</param>
<param name="format">{1}</param>
</result>
</action>
<action name="chart" class="com.strongit.workflow.workflowreport.WorkFlowReportAction" method="chart">
<result name="chart" type="chart">
<param name="width">650</param>
<param name="height">370</param>
</result>
</action>
</package>
</struts>
分享到:
相关推荐
struts.xml和applicationContext.xml、web.xml的配置
struts.xml文件配置解释,对action配置进行说明
struts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.doc
struts.xml文件详解示例代码,可以参照http://blog.csdn.net/jiajia333666/article/details/47979919 阅读。
Dom4j解析struts2框架的struts.xml,自定义struts框架需要解析配置文件
struts.xml的错误解决办法,解决错误
struts.xml常用配置解析 网上转载
struts.xml的要准备的jar包,比较齐全啊
struts-config.xml struts标准配置文件 struts-config
介绍一种让Struts.xml有提示的方法
NULL 博文链接:https://wellfrog.iteye.com/blog/612014
struts.xml配置文件详解struts.xml配置文件详解struts.xml配置文件详解
Struts框架中struts-config.xml文件配置小结
SSH整合struts.xml文件
SSH(Struts,Spring,Hibernate)struts.xml文件配置
dom4j解析struts.xml需要,上一次上传忘了这个包装类
struts-config.xml配置文件对学struts的人必备的查找资料。
sturts模板、用Eclipse的时候大家可以下载下来使用