严重: Servlet.service() for servlet UserServlet threw exception

java.lang.NullPointerExceptionatcom.dao.UserDAO.login(UserDAO.java:24)atcom.action.Us... java.lang.NullPointerException
at com.dao.UserDAO.login(UserDAO.java:24)
at com.action.UserServlet.login(UserServlet.java:49)
at com.action.UserServlet.doPost(UserServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
这是错误
下面是UserDAO.java
package com.dao;
import com.model.UserForm;
import com.tools.ConnDB;
import java.sql.*;
public class UserDAO {
private ConnDB conn;
public UserDAO() {
conn = new ConnDB();
}
//验证用户的方法,返回为1表示登录成功,否则表示登录失败
public int login(UserForm m){
int flag=0;
String sql = "SELECT * FROM tb_user where userName='" +
m.getUserName() + "'";
try {
ResultSet rs = conn.executeQuery(sql);

if (rs.next()) {
String pwd = m.getPwd();
System.out.println("密码:"+pwd);
if (pwd.equals(rs.getString(3))) {
flag = 1;
rs.last();
int rowSum = rs.getRow();
rs.first();
if (rowSum != 1) {
flag = 0;
System.out.print("获取的row的值:" + sql + rowSum);
}
} else {
flag = 0;
}
}else{
flag = 0;
}
} catch (SQLException ex) {
flag = 0;
}
return flag;
}
}

哪个大神救救我
展开
 我来答
百度网友15b6e7c
2013-06-24 · 超过31用户采纳过TA的回答
知道答主
回答量:81
采纳率:0%
帮助的人:91.2万
展开全部
这个是因为你的pwd是null,所以你先确定下pwd是否获取到了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式