Struts 注册、登陆、email实例解析


一、 web.xml<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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部分

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 373.5pt; HEIGHT: 186pt" type="#_x0000_t75" o:ole=""><p align="center"><img src="http://www.csdn.net/Develop/ArticleImages/25/25061/CSDN_Dev_Image_2004-3-11706500.emz" width="467" οnlοad="javascript:if(this.width&gt;screen.width-333)this.width=screen.width-333" o:title=""></p></shape>

七、 logon部分

<shape id="_x0000_i1026" style="WIDTH: 357.75pt; HEIGHT: 162.75pt" type="#_x0000_t75" o:ole=""><p align="center"><img src="http://www.csdn.net/Develop/ArticleImages/25/25061/CSDN_Dev_Image_2004-3-11706502.emz" width="467" οnlοad="javascript:if(this.width&gt;screen.width-333)this.width=screen.width-333" o:title=""></p></shape>

八、 logoff部分

<shape id="_x0000_i1027" style="WIDTH: 350.25pt; HEIGHT: 63.75pt" type="#_x0000_t75" o:ole=""><p align="center"><img src="http://www.csdn.net/Develop/ArticleImages/25/25061/CSDN_Dev_Image_2004-3-11706504.emz" οnlοad="javascript:if(this.width&gt;screen.width-333)this.width=screen.width-333" o:title=""></p></shape>

九、 subscription部分

<shape id="_x0000_i1028" style="WIDTH: 504.75pt; HEIGHT: 175.5pt" type="#_x0000_t75" o:ole=""><p align="center"><img src="http://www.csdn.net/Develop/ArticleImages/25/25061/CSDN_Dev_Image_2004-3-11706506.emz" width="467" οnlοad="javascript:if(this.width&gt;screen.width-333)this.width=screen.width-333" o:title=""></p></shape>

以上内容,是我自己的理解,不当之处还请各位批评指正,谢谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值