<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!—
定义FormBean
-->
<form-beans>
<!—
DynaValidatorForm 的 FormBean可以实现继承,这里的BaseForm就是一个抽象类,包含3个属性
-->
<!-- BaseAction form bean (abstract) -->
<form-bean name="BaseForm"
type="org.apache.struts.validator.DynaValidatorForm">
<!--
属性由名字和类型构成,还可以有初始值
-->
<form-property name="username" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
<form-property name="task" type="java.lang.String"
initial="Create" />
</form-bean>
<!--
LogonForm 继承自BaseForm
-->
<!-- LogonAction form bean -->
<form-bean name="LogonForm" extends="BaseForm" />
<!--
RegistrationForm 继承自BaseForm,多了4个属性
-->
<!-- RegistrationAction form bean -->
<form-bean name="RegistrationForm" extends="BaseForm">
<form-property name="fromAddress" type="java.lang.String" />
<form-property name="fullName" type="java.lang.String" />
<form-property name="password2" type="java.lang.String" />
<form-property name="replyToAddress"
type="java.lang.String" />
</form-bean>
<!--
SubscriptionForm 继承自BaseForm,多了3个属性。reset 属性不知道什么用
-->
<!-- SubscriptionAction form bean -->
<form-bean name="SubscriptionForm" extends="BaseForm">
<form-property name="autoConnect" type="java.lang.Boolean"
initial="FALSE" reset="true" />
<form-property name="host" type="java.lang.String" />
<form-property name="type" type="java.lang.String" />
</form-bean>
</form-beans>
<!--
定义全局的Exception
-->
<global-exceptions />
<!-- ==== Global Forward Definitions ==== -->
<!--
定义全局的Forward
-->
<global-forwards>
<!--
如果在Action里找不到相应的forward,就用这里的forward。
Path不仅可以是jsp文件,而且可以是下一个action,即.do请求。
-->
<forward
name="Logoff"
path="/Logoff.do"/>
<forward
name="Logon"
path="/Logon.do"/>
<forward
name="Failure"
path="/Error.do"/>
</global-forwards>
<!--
定义Action-Mapping
-->
<action-mappings>
<!--
通配符定义的action,例如/Logon.do的请求,页面转向/Logon.jsp
定义在最前面,在其他位置找不到相应的配置,才执行此配置
-->
<!-- Display any other page (Logon, MainMenu) - Wildcards must come first! -->
<action path="/*" forward="/{1}.jsp"></action>
<!--
对于/Welcome.do的请求,要经过WelcomeAction处理之后,如果是返回Success,才转向/Welcome.jsp
-->
<!-- Display welcome page -->
<action path="/Welcome"
type="com.yourcompany.struts.apps.mailreader.action.WelcomeAction">
<forward name="Success" path="/Welcome.jsp" />
</action>
<!--
实际没用,只是为了学习
-->
<!-- Display welcome page
<action path="/Welcome" forward="/Welcome.jsp" />
-->
<!--
Logoff之前,用LogoffAction作一些处理,最后回到Welcome.do
-->
<!-- Process a user logoff -->
<action
path="/Logoff"
type="com.yourcompany.struts.apps.mailreader.action.LogoffAction">
<forward
name="Success"
path="/Welcome.do"/>
</action>
<!--
设置Local之前,用LocaleAction作一些处理,最后回到Welcome.do
Parameter属性是定义MappingDispatchAction类里的方法名,但这里的Success只是表示一个参数,因为LocaleAction里定义了一个execute方法。
用途是:target = mapping.getParameter();
-->
<!-- Change locale action -->
<action
path="/Locale"
type="com.yourcompany.struts.apps.mailreader.action.LocaleAction"
parameter="Success">
<forward
name="Success"
path="/Welcome.do"/>
</action>
<!--
登录的Action,validate表示用了服务端验证,和plugin有关,如果验证失败就让页面转入input标识的forward请求。
Name指出了ActionForm的名字
Cancellable不知道是什么意思
-->
<!-- Process a user logon -->
<action
path="/SubmitLogon"
type="com.yourcompany.struts.apps.mailreader.action.LogonAction"
name="LogonForm"
scope="request"
cancellable="true"
validate="true"
input="Logon">
<!--
如果抛出ExpiredPasswordException就转入/ChangePassword.do请求
-->
<exception
key="expired.password"
type="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException"
path="/ChangePassword.do"/>
<forward
name="Success"
path="/MainMenu.do"/>
</action>
<!--
类似ActionForm,Action也可以用继承。为了防止抽象的Action被请求,故用//作为前缀。
参数{1}代表子类的通配符*
-->
<!-- "Abstract" mapping to use as base -->
<!-- Input like as forward -->
<action path="//BaseAction" input="Input"
type="com.yourcompany.struts.apps.mailreader.action.{1}Action"
name="{1}Form" scope="request">
<forward name="Success" path="/{1}.jsp" />
<forward name="Input" path="/{1}.jsp" />
</action>
<!--
/Delete*通配符匹配action,减少配置文件内容。
例如/DeleteSubscription. 父类的参数{1}就代表Subscription
Parameter=Delete表示,执行SubscriptionAction的Delete函数。
-->
<action path="/Delete*" extends="//BaseAction"
parameter="Delete" validate="false" />
<action path="/Edit*" extends="//BaseAction" parameter="Edit"
validate="false" />
<action path="/Save*" extends="//BaseAction" parameter="Save"
cancellable="true" validate="true">
<forward name="Success" path="/MainMenu.do" />
</action>
<!-- Matches SaveSubscription action -->
<!-- If extends understood wildcards, we could specify only Success here. -->
<action
path="/SaveSubscription"
extends="/Save*"
type="com.yourcompany.struts.apps.mailreader.action.SubscriptionAction"
name="SubscriptionForm">
<forward
name="Success"
path="/EditRegistration.do"/>
<forward
name="Input"
path="/Subscription.do"/>
</action>
<!-- Display the "walking tour" documentation -->
<action
path="/Tour"
forward="/tour.html"/>
</action-mappings>
<!-- ==== Controller Configuration ==== -->
<!--
没弄清楚啥意思,虽然下面有注释
-->
<controller
pagePattern="$M$P"
inputForward="true"/>
<!-- pagePattern: use this pattern when creating URIs to resources.
$M=module, $P=path -->
<!-- inputForward: The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<!--
定义资源文件
-->
<message-resources
parameter="com.yourcompany.struts.ApplicationResources" />
<message-resources
parameter="com.yourcompany.struts.AlternateApplicationResources"
key="alternate" />
<!--
定义插件
-->
<!--
和验证有关,使用了common-validator
-->
<plug-in
className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
<!--
和MailReader的xml数据库有关,这里用到一个被封装好的jar包
-->
<plug-in
className="com.yourcompany.struts.apps.mailreader.plugin.MemoryDatabasePlugIn">
<set-property property="pathname" value="/WEB-INF/database.xml" />
</plug-in>
<!--
和下拉框有关,有点过于复杂
-->
<plug-in
className="org.apache.struts.plugins.DigestingPlugIn">
<set-property
property="key"
value="serverTypes"/>
<set-property
property="configPath"
value="/WEB-INF/server-types.xml"/>
<set-property
property="digesterPath"
value="/WEB-INF/lvb-digester-rules.xml"/>
</plug-in>
</struts-config>
|