当前位置: 代码迷 >> Eclipse >> 关于编辑jsp中出现NumberFormatException的有关问题
  详细解决方案

关于编辑jsp中出现NumberFormatException的有关问题

热度:62   发布时间:2016-04-23 13:34:48.0
关于编辑jsp中出现NumberFormatException的问题
出错语句:int rootId =Integer.parseInt(request.getParameter("rootid"));

说明:上一个文件是回帖,点击“提交”进入下一个文件ReplyOK.jsp,
同样的一条语句在上一个jsp文件中使用没有问题,直接copy到下一个文件就提示出错了,

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /ReplyOK.jsp at line 8

5: <% 
6: request.setCharacterEncoding("GBK");
7: int id = Integer.parseInt(request.getParameter("id"));
8: int rootId =Integer.parseInt((String)request.getParameter("rootid"));
9: String title = request.getParameter("title");
10: String cont = request.getParameter("cont");

————————————————————
而在console中有一句提示:
at org.apache.jsp.ReplyOK_jsp._jspService(ReplyOK_jsp.java:60)

 我的这个文件没有 60行啊.....点击上句弹出提示框:Source not found for org.apache.jsp.ReplyOK_jsp.
----------------
补充:在回复页面,点击:“提交”后,地址栏显示:
http://localhost:8080/BBS/Reply.jsp?id=1&rootid=1

在下一个文件中,使用trycatch,
try{
id = Integer.parseInt(request.getParameter("id"));
rootId =Integer.parseInt(request.getParameter("rootid"));
}catch(NumberFormatException e){
System.out.println("id = "+ request.getParameter("id"));
System.out.println("rootid = "+ request.getParameter("rootid"));
}
显示 id = 1 
  rootid = null

这是怎么回事儿?求助~

------解决方案--------------------
既然地址栏是:http://localhost:8080/BBS/Reply.jsp?id=1&rootid=1
那么rootid就传过去了,怎么会获取不到呢?
我也不明白了,帮楼主顶一下!
------解决方案--------------------
再调试一下看看
代码迷推荐解决方案:An exception occurred processing JSP page,http://www.daimami.com/search?q=33144
  相关解决方案