一、 web.xml
1. <!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config-registration.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2. <!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib>
二、 struts-config.xml
1. <form-beans>
<!-- Logon form bean -->
<form-bean name="logonForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
2. <global-forwards>
<forward name="logoff" path="/logoff.do"/>
<forward name="logon" path="/logon.jsp"/>
<forward name="success" path="/mainMenu.jsp"/>
</global-forwards>
3. <action-mappings>
………………
<action path="/tour" forward="/tour.htm"> </action>
………………
</action-mappings>
4. <controller>
<!-- The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<set-property property="inputForward" value="true"/>
</controller>
5. <message-resources parameter="zwd_10.ApplicationResources"/>
<message-resources parameter="org.apache.struts.webapp.example.AlternateApplicationResources" key="alternate">
</message-resources>
6. <plug-in className="org.apache.struts.plugins.ModuleConfigVerifier"/>
<plug-in className="zwd_10.memory.MemoryDatabasePlugIn">
<set-property property="pathname" value="/WEB-INF/database.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
三、 struts-config-registration.xml
定义Registration的有关操作:
1. form-bean: registrationForm
2. global-forwards:
<forward name="registration" path="/registration.jsp"/>
3. action-mappings:
<action path="/editRegistration"
type="zwd_10.EditRegistrationAction"
attribute="registrationForm"
scope="request"
validate="false">
<forward name="success" path="/registration.jsp"/>
</action>
<action path="/saveRegistration"
type="zwd_10.SaveRegistrationAction"
name="registrationForm"
scope="request"
input="registration"/>
四、 Java文件内容
1. Constants:// 常量类
public final class Constants {
public static final String Package = "zwd_10";
public static final String DATABASE_KEY = "database";
public static final String SUBSCRIPTION_KEY = "subscription";
public static final String USER_KEY = "user"; }
2. User:// 接口
public interface User {
public UserDatabase getDatabase();
public String getFromAddress();
public void setFromAddress(String fromAddress);
public String getFullName();
public void setFullName(String fullName);
public String getPassword();
public void setPassword(String password);
public String getReplyToAddress();
public void setReplyToAddress(String replyToAddress);
public Subscription[ ] getSubscriptions();
public String getUsername();
public Subscription createSubscription(String host);
public Subscription findSubscription(String host);
public void removeSubscription(Subscription subscription); }
MemoryUser://实现User接口
3. UserDatabase:// 接口
public interface UserDatabase {
public User createUser(String username);
public void close() throws Exception;
public User findUser(String username);
public User[ ] findUsers();
public void open() throws Exception;
public void removeUser(User user);
public void save() throws Exception; }
MemoryUserDatabase://实现MemoryUserDatabase接口
4. Subscription:// 接口
public interface Subscription {
public boolean getAutoConnect();
public void setAutoConnect(boolean autoConnect);
public String getHost();
public String getPassword();
public void setPassword(String password);
public String getType();
public void setType(String type);
public User getUser();
public String getUsername();
public void setUsername(String username); }
MemorySubscription://实现MemoryUserDatabase接口
5. MemoryDatabasePlugIn://实现PlugIn接口,在struts-config.xml中有说明
五、 app.tld(自定义的标签库)
1. 声明CheckLogonTag ―――― 对应CheckLogonTag.java
CheckLogonTag:// extends TagSupport接口
2. 声明LinkSubscriptionTag ―――― 对应LinkSubscriptionTag.java
LinkSubscriptionTag:// extends TagSupport接口
3. 声明LinkUserTag ―――― 对应LinkUserTag.java
LinkUserTag:// extends TagSupport接口
六、 registration部分
七、 logon部分
八、 logoff部分
九、 subscription部分
以上内容,是我自己的理解,不当之处还请各位批评指正,谢谢。