当前位置: 代码迷 >> Java Web开发 >> 一个JSP小问题(空指针)
  详细解决方案

一个JSP小问题(空指针)

热度:232   发布时间:2007-11-11 19:02:16.0
一个JSP小问题(空指针)

type Exception report

message

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

exception

org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: ""

root cause

java.lang.NumberFormatException: For input string: ""

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server Platform Edition 9.0_01 logs.

//错误代码
<%@page contentType="text/html"%>
<%@page pageEncoding="GBK" import="model.*"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id="thing" scope="page" class="model.Things" />
<jsp:setProperty name="thing" property="*" />
<%
Catalog c = CatalogService.getCatalog(Integer.parseInt(request.getParameter("catalogID")));
CatalogService.addThing(c,thing);
//request.setAttribute("c",c)
%>
<jsp:forward page="ListThings.jsp?id=${c.ID}" />

搜索更多相关主题的帖子: 指针  JSP  

----------------解决方案--------------------------------------------------------
request.getParameter("catalogID")这里获取的catalogID你地址里有传过来的时候值错了
----------------解决方案--------------------------------------------------------
request.getParameter("catalogID")这个值获取的时候应该空了,所以你进行类型转换的时候出现了错误。
Catalog c = CatalogService.getCatalog(request.getParameter!=null?Integer.parseInt(request.getParameter("catalogID")):当等于空时候你要赋值);


----------------解决方案--------------------------------------------------------
谢谢
----------------解决方案--------------------------------------------------------
  相关解决方案