我在网站中输入http://localhost:8080/1.jsp?ID=123  
1.jsp文件中有      String ID = request.getParameter(“ID”); 但是提示说这句参数错误 !  用FORM的方法可以成功。请问是什么原因?如何改?才能把ID=123的值传给jsp中,不用FORM

解决方案 »

  1.   

    能不能把你的相关的jsp都贴出来,你给出上面的描述都没有问题啊!
      

  2.   

    单纯的http://localhost:8080/1.jsp?ID=123  
     没有问题 可以得到啊
      

  3.   

    看看是post还是get方法的问题。
      

  4.   

    1.jsp 代码如下 
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page import="com.mysql.jdbc.Driver" %>
    <%@ page import="java.sql.*" %>
    <%
               out.println(" "+request.getParameter(“ID”)+" "); 
    %>然后输入 http://localhost:8080/1.jsp?ID=1就会出现错误提示 内容为:
    An error occurred at line: 43 in the jsp file: /1.jsp
    The method getParameter(String) in the type ServletRequest is not applicable for the arguments ()
      

  5.   

              out.println(" "+request.getParameter(“ID”)+" "); 换成
     String ID = request.getParameter(“ID”);   也是一样
      

  6.   

    http://localhost:8080/1.jsp?ID=123 
    这样<%=request.getParameter("ID") %>完全可以获得啊!
      

  7.   

    晕了。难道是我人品不好? 是不是什么环境变量没有设置的原因?再问个问题  如果我用socket 模拟 POST请求 。 例如 
    char*   req="POST /1.jsp HTTP/1.0\r\n"
    "From:   local\r\n"
    "User-Agent:   post_test/1.0\r\n"   
    "Content-Type:   application/x-www-form-urlencoded\r\n"   
    "Content-Length:  4\r\n\r\n"   
    "ID=1";那么我在客户端一样可以用String ID = request.getParameter(“ID”);   获得ID值吗?如果不能需要什么条件?