<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>
 
    
<%
 String strId = request.getParameter("id");
 String strRoot = request.getParameter("rootid");
   
 int id = Integer.parseInt(strId);
 int rootId = Integer.parseInt(strRoot);
   


%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<form action="ReplyOK.jsp" method="post">
<input type="hidden" name="id" value="<%=id %>">
<input type="hidden" name="rootId" value="<%=rootId %>">
  <table border="1">
  <tr>
    <td>
      <input type="text" name="title" size=80>
    </td>
   </tr>
   <tr>
     <td>
      <textarea cols="80" rows="12" name="cont"></textarea>
     </td>
    </tr>
    <tr>
     <td>
      <input type="submit" value="提交">
    </td>
  </tr>
  </table>
  </form>
</body>
</html>

解决方案 »

  1.   

    <%=id %> id需是作用域中的值
      

  2.   

    [code=Java]
    String strId = request.getParameter("id");
    String strRoot = request.getParameter("rootid");
        
    int id = Integer.parseInt(strId);
    int rootId = Integer.parseInt(strRoot);
    [/code
    觉得上面的这里可能会出错!
    当你strId,strRoot没有值的时候会出错。因为在没有值的情况下,你把一个空对象的转换成Interger类型,这样显然会抱错!你还是在转换前,加以判断!
    例如: request.getParameter("rootid") 是否等于null
      

  3.   


    int id = Integer.parseInt(strId);
    int rootId = Integer.parseInt(strRoot);加上try异常处理!!!
      

  4.   

     String strId = request.getParameter("id");
     String strRoot = request.getParameter("rootid");你要确定这两个取到值才能接下来的类型转换
    你用 System.out.println(strId);
     System.out.println(strRoot);
    打出来看看,取到的是什么
      

  5.   


    <%@ page language="java" contentType="text/html; charset=gbk"
      pageEncoding="gbk"%>
    改成
    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
      

  6.   

    如果strId跟strRoot 两个参数不转换类型的话就不会报错,应该是因为得到的参数除了问题,使得无法转换两个参数为整数型
      

  7.   

    他那个包的应就是 "java.lang.NumberFormatException"这个错误,这个简单的页面只有几个小脚本,也就是在request中得到参数是null,然而没办法转换成Integer。所以应该是这个错!这个纯属个人分析,只供参考!呵呵!
      

  8.   

    String strId = request.getParameter("id");
    <input type="hidden" name="id" value="<%=id %>">
    应该改为:<input type="hidden" name="id" value="<%=strid %>">
      

  9.   

    <input type="hidden" name="id" value="<%=id %>">
    <input type="hidden" name="rootId" value="<%=rootId %>">如果strId、strRoot都是整数,都改成
    <input type="hidden" name="id" value="<%=strId %>">
    <input type="hidden" name="rootId" value="<%=strRoot %>">
    这样就可以了,不用再转换类型多此一举
      

  10.   

    接收到的值是null,转化为数字异常
      

  11.   

    int id = Integer.parseInt(strId);
    int rootId = Integer.parseInt(strRoot);
    这2名前先加以判断strId,strRoot是否为null呗,或者用try catch括起来
    int id,rootId;
    try{
        id = Integer.parseInt(strId);
        rootId = Integer.parseInt(strRoot);
    }
    catch{
        id = 0;
        rootId = 0;
    }
      

  12.   

    String strId = request.getParameter("id");
    String strRoot = request.getParameter("rootid");在第一次加载的时候获得的 strId,strRoot都是null 所以在后面转换成数字的时候抛出了异常 
      

  13.   

    String strId = request.getParameter("id");
     String strRoot = request.getParameter("rootid");
        
    int id = Integer.parseInt(strId);
    int rootId = Integer.parseInt(strRoot);第一次加载的时候获取到null值,之后就会报类型转换的错误了。
      

  14.   

    <%@ page language="java" contentType="text/html; charset=gbk"
      pageEncoding="gbk"%>需设两个“gbk”吗???
      

  15.   

    你先去运行一下:
    String str = "shit";
    int num = Integer.parseInt(str);
      

  16.   

    try catch 后天还报错,,这样也不好吧!