Passion-Roma 2010-03-23 21:18
浏览 293
已采纳

方法未定义

这是部分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.

我试了很多方法都不好使,请各位大侠出手相助。。。

  • 写回答

11条回答 默认 最新

  • iteye_566 2010-03-24 09:29
    关注

    你的程序里面是不是不同的包中有相同的UserManager,你页面导入的时候,导错类了,其他的问题,楼上都找出来了,你重新发布一下,再重试一下。。。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(10条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀