- <?xml version="1.0" encoding="ISO-8859-1" ?>
- <!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>
- <!-- ==================== Data Source Configuration ========================-->
- <data-sources>
- <!-- default datasource -->
- <data-source type="org.apache.commons.dbcp.BasicDataSource">
- <set-property property="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
- <set-property property="url" value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=northwind" />
- <set-property property="username" value="sa" />
- <set-property property="password" value="" />
- <set-property property="maxIdle" value="30" />
- <set-property property="maxActive" value="100" />
- <set-property property="maxWait" value="10000" />
- </data-source>
- <!-- non-default datasource -->
- <data-source key="ds1" type="org.apache.commons.dbcp.BasicDataSource">
- <set-property property="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
- <set-property property="url" value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=northwind" />
- <set-property property="username" value="sa" />
- <set-property property="password" value="" />
- <set-property property="maxIdle" value="30" />
- <set-property property="maxActive" value="100" />
- <set-property property="maxWait" value="10000" />
- </data-source>
- ...
- </data-sources>
- <!-- ===================== Form Bean Definitions ===========================-->
- <form-beans>
- <!-- extends org.apache.struts.action.ActionForm -->
- <form-bean name="inputForm" type="app.InputForm"/>
- <!-- Custom FormBeanConfig -->
- <form-bean className="app.MyFormBeanConfig"
- name="inputForm"
- type="app.InputForm"/>
- <!-- dynamic form-bean (extends org.apache.struts.action.DynaActionForm) -->
- <form-bean name="logonForm"
- type="org.apache.struts.action.DynaActionForm">
- <form-property name="username" type="java.lang.String"/>
- <form-property name="password" type="java.lang.String"/>
- <form-property name="district" type="java.lang.String" initial="Heping"/>
- <form-property name="telephone" type="java.lang.String[]" size="2"/>
- </form-bean>
- ...
- </form-beans>
- <!-- ====================== Global Exception Definitions ================== -->
- <global-exceptions>
- <exception key="expired.password"
- type="app.ExpiredPasswordException"
- path="/changePassword.jsp"/>
- <!-- bundle -->
- <exception bundle="msgrsc1"
- key="exception.thrown"
- type="java.lang.Exception"
- scope="session"/>
- <!-- handler -->
- <exception handler="app.MyExceptionHandler"
- key="exception.thrown"
- type="java.lang.Exception"/>
- ...
- </global-exceptions>
- <!-- ====================== Global Forward Definitions ==================== -->
- <global-forwards>
- <forward name="login" path="/login.jsp" />
- <!-- forward to an action -->
- <forward name="welcome" path="/welcome.do" />
- <!-- redirect -->
- <forward name="test" path="/test.jsp" redirect="true"/>
- <!-- contextRelative -->
- <forward name="process" path="/process.jsp" contextRelative="true"/>
- <!-- module -->
- <forward name="success" path="/success.jsp" module="/moduleA"/>
- <forward name="success" path="/success.jsp" module="/"/>
- ...
- </global-forwards>
- <!-- ====================== Action Mapping Definitions ==================== -->
- <action-mappings>
- <!-- forward or ForwardAction -->
- <action path="/welcome1" forward="/pages/welcome1.jsp"/>
- <action path="/input1"
- type="org.apache.struts.actions.ForwardAction"
- parameter="/pages/input1.jsp"/>
- <!-- include or IncludeAction -->
- <action path="/welcome2" include="/pages/welcome2.jsp"/>
- <action path="/input2"
- type="org.apache.struts.actions.IncludeAction"
- parameter="/pages/input2.jsp"/>
- <!-- type -->
- <action path="/InputSubmit1"
- type="app.MyInputAction"
- name="inputForm"
- scope="request"
- validate="true"
- input="/pages/input.jsp"/>
- <!-- attribute -->
- <action attribute="inputA"
- path="/InputSubmit2"
- type="app.MyInputAction"
- name="inputForm"
- validate="true"
- input="/pages/input.jsp"/>
- <!-- unknown -->
- <action path="/InputSubmit3"
- type="app.MyInputAction"
- name="inputForm"
- scope="request"
- unknown="true"
- validate="true"
- input="/pages/input.jsp"/>
- <!-- wildcard -->
- <action path="/edit*"
- type="app.Edit{1}Action"
- name="inputForm"
- scope="request"
- validate="true"
- input="/pages/edit{1}.jsp"/>
- <!-- local forward and exception -->
- <action path="/InputSubmit1"
- type="app.MyInputAction"
- name="inputForm"
- scope="request"
- validate="true"
- input="/pages/input.jsp">
- <forward name="success" path="/success.jsp"/>
- <forward name="failure" path="/failure.jsp"/>
- <exception key="expired.password"
- type="app.ExpiredPasswordException"
- path="/changePassword.jsp"/>
- </action>
- ...
- </action-mappings>
- <!-- ======================= Controller Configuration ===================== -->
- <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
- <!--
- <== inputForward ==>
- <controller inputForward="true" />
- or
- <== locale ==>
- <controller locale="false" />
- -->
- <!-- ====================== Message Resources Definitions ================= -->
- <!-- default message-resources -->
- <message-resources parameter="app.resource.MyResources" />
- <!-- non-default message-resources -->
- <message-resources key="msgrsc1" parameter="app.resource.MyResources" />
- <!-- null -->
- <message-resources key="msgrsc1" parameter="app.resource.MyResources" null="false" />
- <!-- ====================== Plug Ins Configuration ======================== -->
- <!-- **************************** Validator plugin ************************ -->
- <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
- <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
- </plug-in>
- <!-- ************************* Tiles plugin ******************************* -->
- <!-- This plugin initialize Tiles definition factory. This later can takes some
- parameters explained here after. The plugin first read parameters from
- web.xml, thenoverload them with parameters defined here. All parameters
- are optional.
- The plugin should be declared in each struts-config file.
- - definitions-config: (optional)
- Specify configuration file names. There can be several comma
- separated file names (default: ?? )
- - moduleAware: (optional - struts1.1)
- Specify if the Tiles definition factory is module aware. If true
- (default), there will be one factory for each Struts module.
- If false, there will be one common factory for all module. In this
- later case, it is still needed to declare one plugin per module.
- The factory will be initialized with parameters found in the first
- initialized plugin (generally the one associated with the default
- module).
- true : One factory per module. (default)
- false : one single shared factory for all modules
- - definitions-parser-validate: (optional)
- Specify if xml parser should validate the Tiles configuration file.
- true : validate. DTD should be specified in file header (default)
- false : no validation
- Paths found in Tiles definitions are relative to the main context.
- -->
- <plug-in className="org.apache.struts.tiles.TilesPlugin" >
- <!-- Path to XML definition file -->
- <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
- <!-- Set Module-awareness to true -->
- <set-property property="moduleAware" value="true" />
- <set-property property="definitions-parser-validate" value="true" />
- </plug-in>
- </struts-config>
Struts-config 常用配置
最新推荐文章于 2021-01-19 11:47:48 发布