日期:2014-05-18 浏览次数:20764 次
<form name="form" method="post">
User<s:textfield name="username"/><br/>
Password<s:password name="password"/><br/>
<input type="submit" name="submit1" value="submit1" onclick="document.form.action='struts/login1!add';document.form.submit();">
</form>
<package name="default" namespace="/struts" extends="struts-default">
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="login*" class="actionClass.LoginAction{1}" >
<result >
/Success.jsp
</result>
</action>
</package>
package actionClass;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction1 extends ActionSupport {
private Map request;
private Map session ;
private Map application;
private String username;
private String password;
public LoginAction1( ){
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Map getRequest() {
return request;
}
public void setRequest(Map request) {
this.request = request;
}
public Map getSession() {
return session;
}
public void setSession(Map session) {
this.session = session;
}
public Map getApplication() {
return application;
}
public&