问答详情
源自:3-7 request对象(上)

跳转时老是报500错误

for(int i=0; i < favorites.length; i++)

    {

    out.print(favorites[i]+"&nbsp;&nbsp;");//有错误

    }

类型异常报告

消息 在第36行处理JSP页面/request.jsp时发生异常

description 服务器遇到内部错误,导致无法完成此请求。

例外

org.apache.jasper.JasperException:在第36行处理JSP页面/request.jsp时发生异常33:鐖卞ソ锛%%%%%34:if(request.getParameterValues(“favorite”)!= null){35:String [] favorites = request.getParameterValues(“favorites”);36:for(int i = 0; i <favorites.length; i ++)37:{38:out.print(收藏夹[i] +“&nbsp;&nbsp;”); //链接璇璇 39:}堆栈跟踪:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

根本原因

显示java.lang.NullPointerException
	org.apache.jsp.request_jsp._jspService(request_jsp.java:157)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note备注 根本原因的完整堆栈跟踪在Apache Tomcat /8.0.43日志中。


Apache Tomcat / 8.0.43


提问者:weixin_慕UI2156548 2019-05-31 17:30

个回答

  • 一个要秃头的女人
    2019-09-29 14:49:07

    if(request.getParameterValues(“favorite”)!= null)

    改成

    if(request.getParameterValues(“favorites”)!= null)

  • qq_Qi_14
    2019-06-01 10:26:59

    加一个判断语句,

    if(request.getParameterValues("favorite") != null)