自己建的又有如下错误~
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:514)
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:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause java.lang.NullPointerException
docrm.LoginAction.execute(LoginAction.java:66)
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:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.用STRUTS框架

解决方案 »

  1.   

    404没有找到文件
    NullpointerException, 遇到空指针了楼主第一步不要要求太高了, 先从网页/jsp开始吧
      

  2.   

    检查web-inf文件夹下的web.xml
     
    察看Servlet映射是否正确
      

  3.   

    楼主第一帖帖出来的问题应该是web.xml中servlet映射配置出了问题,很可能是打字错误;)第二帖报的是空指针错误,注意检查你的.LoginAction的66行,是不是调用了一个未经初始化的对象。在编写范例程序时,即便是模仿,输入错误还是很常见的;)
      

  4.   

    谢谢大家~,TinyJimmy(Jimmy) 和HPFYEAH(牛牛爱双鱼)能留一下QQ么~?权作为讨论好么~?
      

  5.   

    message Servlet actionServlet is not available
    这个错误在使用Struts的时候经常出现.可能是你的actionServlet有错误,也可能是你的Struts-config.xml配置的问题.
    最好把你的struts-config.xml和你的Action贴出来.大家好帮你分析.
      

  6.   

    public class LoginAction extends Action
    {
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)throws Exception
    {
    UserForm userform=(UserForm)form;
    String name=(String)userform.getName();
    String psw=(String)userform.getPsw();
    DB db=new DB();
    HttpSession session=request.getSession(true);
    String PageForward=null; //Vector newsList=new Vector();
    ActionMessages errors=new ActionMessages();

    if(InterUser.CheckUser(db,name,psw))
    {
    session.setAttribute(Constants.LOGIN_USERNAME_KEY,name);
    PageForward="toEmployeeMain";
    }
    else
    {
    errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("errors.accessDeny"));
    if(!errors.isEmpty())
    {
    saveErrors(request,errors);
    }
    PageForward="toWrong";
    }
      

  7.   

    public class InterUser
    {
    private String username=null;
    private String password=null;
    private String grade=null;
    private int empId=0;
             public static boolean CheckUser(DB db,String username,String password)throws Exception
    {
    String strSql;
    ResultSet rs;
    strSql="select * from employee where username='"+username+"'"+" and password='"+password+"'";
    rs=db.OpenSql(strSql); 
    if(rs!=null)
    {
    if(rs.next())
    {
    return true;
    }
    else
    {
    return false;
    }
    }
    else
    {
    return false;
    }
    }
      

  8.   

    public class DB
    {
    Connection conn=null;
    Statement stmt=null;
    ResultSet rs=null;
             public ResultSet OpenSql(String sql)
    {
    try
    {

         stmt=conn.createStatement();
        
         rs=stmt.executeQuery(sql);
        }catch(SQLException ex)
        {
         ex.printStackTrace();
        }
        
        return rs;
      }
      

  9.   

    问题已经解决
    大家注意到InterUser.CheckUser(db,name,psw)方法了么~?
    原程序在实现里外层的IF语句并没有
                      if(rs!=null)
    {
    if(rs.next())
    {
    return true;
    }
    else
    {
    return false;
    }
    }也就是说当用户验证失败select出空RESULTSET后
    会返回空指针~
    当加上外层的IF-ELSE后就好了~
    帖出来希望大家别犯我的错误~如果有高手愿意以JAVA技术在BS结构中的应用作为讨论的话~
    我可以建个群大家一起讨论好么~
    有人愿意的话留下QQ~我们的口号:坚决不建死群~!