*************userCheckAction.java*********************package com.webiter.manager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.domain.UserForm;
import com.service.UserFacade;
import com.service.UserFacadeImpl;
import com.tool.Chinese;
public class UserCheckAction extends Action {private UserFacade facade = null;
  public UserCheckAction() {
    this.facade = new UserFacadeImpl();
  }public ActionForward execute(ActionMapping mapping, ActionForm actionForm,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) actionForm;// TODO Auto-generated method stub    userForm.setUser_name(Chinese.str(request.getParameter("name")));    UserForm form = this.facade.checkUser(userForm);
    String mm = Chinese.str(request.getParameter("mm"));
    if (form == null) {
      return mapping.findForward("checkFail");
    }
    else if (!form.getUser_mm().equals(mm)) {
      return mapping.findForward("checkFail");
    }    request.setAttribute("form", form);
    return mapping.findForward("checkSuccess");
}
}************land.jsp***************
<%@ page contentType="text/html; charset=gb2312"%>
<%session.invalidate();%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>操作员登陆 </title>
<style type="text/css">
<!--
.style1 {font-size: 24px}
.style2 {
color: #FF0000;
font-weight: bold;
}
.style5 {color: #FF0000}
-->
</style>
</head>
<script language="JavaScript">
function RgTest(){
if(document.form.name.value==""){
window.alert("请输入账号");return false;
}
if(document.form.mm.value==""){
window.alert("请输入密码");return false;
}return true;
}
</script>
<body  >
  <div align="center" class="style1">    <p>&nbsp; </p>
    <table width="334" height="172"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="171" background="images/land.gif">    
    <form name="form" method="post" action="userCheck.do"  onSubmit="return RgTest()">
          <p>&nbsp; </p>
          <table width="79%"  border="0" align="center" cellpadding="0" cellspacing="0">
     <tr>
       <td width="30%" height="26" > <div align="center" class="style2 style5">账号 </div> </td>
       <td width="70%"> <div align="center"> <input type="text" name="name"> </div> </td>
     </tr>
     <tr>
       <td height="25" > <div align="center" class="style2">密码 </div> </td>
       <td> <div align="center"> <input type="password" name="mm"> </div> </td>
     </tr>
   </table>
            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>&nbsp; </td>
              </tr>
            </table>
            <div align="center">
              <input type="image" name="Submit" src="images/land1.gif">
             &nbsp;&nbsp;&nbsp;
              <input type="image" name="reset" src="images/land2.gif" onClick="this.form.reset()">
            </div>
    </form> </td>
      </tr>
    </table>
</div>
</body>
</html> 异常如下description The server encountered an internal error () that prevented it from fulfilling this request.exceptionjavax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causejava.lang.NullPointerException
com.tool.Chinese.str(Chinese.java:9)
com.webiter.manager.UserCheckAction.execute(UserCheckAction.java:49)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 

解决方案 »

  1.   

    空指针异常,
    看看你的UserCheckAction类的49行
      

  2.   

    userForm.setUser_name(Chinese.str(request.getParameter("name"))); 
    这句是干嘛用的.相当有可能有错误!
      

  3.   

    Chinese.str方法里面没有处理参数为null的情况
      

  4.   

    问题明显,Chinese类的9行出错,调试一下,看哪个对象是空的
      

  5.   

    这个是JSP页面的变量出错``你页面上用的数据没有从ACTION   SET过来  页面上找不到就报空指针出错啦```