日期:2014-05-18 浏览次数:20844 次
package com.loginCheck;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String userName=null;
private String userPassword=null;
@Override
public String execute(){
if(userName != null) {
if(userName.equals("wuyanxue")) {
return SUCCESS;
}
}
System.out.println(userName+" "+userPassword);
return ERROR;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserPassword() {
return userPassword;
}
}
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="myResources"></constant>
<package name="example" namespace="" extends="struts-default">
<global-exception-mappings>
<exception-mapping result="Exception" exception="java.lang.Exception">
</exception-mapping>
</global-exception-mappings>
<action name="login" class="com.loginCheck.LoginAction">
<interceptor-ref name="logger" />
<interceptor-ref name="timer" />
<exception-mapping result="SQLException" exception="java.sql.SQLException"></exception-mapping>
<result name="success">
/loginSuccess.jsp
</result>
<result name="error">
/loginFail.jsp
</result>
</action>
</package>
</struts>