我的请求不能从servlet成功的转到JSP,请求大虾帮帮忙,谢谢了!

来源:百度知道 编辑:UC知道 时间:2024/06/01 19:34:14
错误提示:type Exception report

message

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

exception

java.lang.NullPointerException
com.yxq.servlet.PhotoServlet.singlePhoto(PhotoServlet.java:203)
com.yxq.servlet.PhotoServlet.doPost(PhotoServlet.java:48)
com.yxq.servlet.PhotoServlet.doGet(PhotoServlet.java:23)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

public void singlePhoto(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
String strId=(String)request.getAttribute("id");
int id=MyTools.strToint(strId);
PhotoDao photoDao=new PhotoDao();
PhotoBean photoBean=(PhotoBean)photoDao.queryPhoto(i

提示了 java.lang.NullPointerException 异常,说明你的路径跳转正常
问题是 你传的参数 在你的 Photo.jsp 页面为空 自己在servlet调试一下
PhotoBean photoBean=(PhotoBean)photoDao.queryPhoto(id);
request.setAttribute("photoBean",photoBean);

之间 试着打印下photoBean的属性 看看是不是空值 是的话就看看你的类或是方法 因为 类的属性和方法 是你自己定义的 这种问题只能自己慢慢调试了

如果photoBean属性不空 跳转语句改写成重定向方式 跳转试下

错误肯定出在上面

doGet doPost 的方法呢