这是部分user_modify.jsp代码:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="com.bjsxt.drp.sysmgr.domain.*" %>
<%@ page import="com.bjsxt.drp.sysmgr.manager.*" %>
<%
String command = request.getParameter("command");
User user = null;
if("modify".equals(command)){
user.setUserId(request.getParameter("userId"));
user.setUserName(request.getParameter("userName"));
user.setPassword(request.getParameter("password"));
user.setContactTel(request.getParameter("contactTel"));
user.setEmail(request.getParameter("email"));
UserManager.getInstance().modifyUser(user);
}
out.println("修改成功!");
String userId = request.getParameter("userId");//拿到request请求对象中的userId
user = UserManager.getInstance().findUserById(userId);
%>
这是部分UserManager.java的代码:
public void modifyUser(User user){
String sql = "update t_user set user_name=?, password=?, contact_tel=?, email=? " +
"where user_id=? ";
Connection conn = null;
PreparedStatement pstmt = null;
try{
conn = DBUtil.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
pstmt.setString(3, user.getContactTel());
pstmt.setString(4, user.getEmail());
pstmt.setString(5, user.getUserId());
pstmt.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
}finally{
DBUtil.close(pstmt);
DBUtil.close(conn);
}
}
最后运行抛出的异常:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 14 in the jsp file: /sysmgr/user_modify.jsp
The method modifyUser(User) is undefined for the type UserManager
11: user.setPassword(request.getParameter("password"));
12: user.setContactTel(request.getParameter("contactTel"));
13: user.setEmail(request.getParameter("email"));
14: UserManager.getInstance().modifyUser(user);
15: }
16: out.println("修改成功!");
17: String userId = request.getParameter("userId");//拿到request请求对象中的userId
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
我试了很多方法都不好使,请各位大侠出手相助。。。