HttpServletRequest getParameter返回null

环境:win7 64位, Eclipse Java EE Mars Release (4.5.0)

新学习jsp,从http://www.cnblogs.com/coder2012/p/3389979.html学习一简单教程,结果悲剧了

出错部分jsp代码:

Select:

出错部分java代码:

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String c = request.getParameter("select");
        if(c.equals("yes"))
            out.print("Welcome!");
        else
            out.print("I don't like you!");
    }

上面代码中request.getParameter获取的值为null,查了半天,原来getParameter只能获取有name属性的控件值

改成

   

本来就是新手,还被教程坑了

参考:

http://zhidao.baidu.com/link?url=RYdDnZPbOppMEZ725EBe197lSBB_2aqauBDOMtutkH555R7cnpB939RBK6AfS7uE0PUqm0fSJ3ZloKLgY0OE9q

http://www.cnblogs.com/coder2012/p/3389979.html

你可能感兴趣的:(jsp)