qq_32063079
Leo.H.J
2017-10-30 13:30

java servlet 异常新人求帮助

10
  • java
  • servlet与jsp
 type Exception report

message

description **The server encountered an internal error that prevented it from fulfilling this request.**

exception

java.lang.NullPointerException
    cn.edu.lingnan.dao.UserDataDAO.login(UserDataDAO.java:76)
    cn.edu.lingnan.test.UserDataTest.loginTest(UserDataTest.java:55)
    cn.edu.lingnan.servlet.LoginServlet.doGet(LoginServlet.java:28)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

相对应的代码段:
【1】LoginServlet
【1】从页面获取数据
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("网页获取:"+username+password);
//

// 【2】调用后台数据

           UserDataTest udt =new UserDataTest();
           boolean flag = udt.loginTest(username, password);

【2】

public boolean login(UserDataDTO user){
int a = 0;
boolean flag = true;
String sql ="select * from userdata where name =? and password=? and sigal<>0";
Object[] attribute={user.getName(),user.getPassword()};

rs = exectueQuery(sql,attribute);
try {

while(rs.next()){

a++;
}

if(a>0){
System.out.println("登陆成功");
flag = true;
}

【3】
public boolean loginTest(String name,String password){
boolean flag = true;
udto.setName(name);

udto.setPassword(password);
// udto.setPermissions("员工");
flag = udao.login(udto);

return flag;
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答

为你推荐