日期:2014-05-19 浏览次数:20712 次
javax.servlet.ServletException: java.lang.NullPointerException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NullPointerException
com.yourcompany.login.LoginAction.execute(LoginAction.java:19)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
public class LoginAction extends Action {这个是LOGINACTION 第十九行 用红色标记出来了。
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
LoginForm loginForm=(LoginForm)form;
if(loginForm.getLoginname().equals("qwe")){
return mapping.findForward("LoginSuccess");
}else{
return mapping.findForward("LoginFail");
}
}
}
public class LoginForm extends ActionForm {LoginForm。java
private String loginname=null;
private String password=null;
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
<struts-config>
<data-sources />
<form-beans>
<form-bean name="loginForm" type="com.yourcompany.login.LoginForm"></form-bean>
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
path="/login" type="com.yourcompany.login.LoginAction" name="loginForm">
<forward name="LoginSuccess" path="/loginsuccess.jsp"></forward>
&nb