本文共 550 字,大约阅读时间需要 1 分钟。
今天看完网课在实践的时候发现doPost方法无法读取道html表单数据的值
doPost代码如下:protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("post"); BufferedReader reader = request.getReader(); String line=null; while ((line=reader.readLine())!=null) { System.out.println(line); } }
html表单代码如下:
运行tomcat服务器再html表单提交数据后发现servlet并没有获取到注册信息
最终发现问题: html表单中需要添加name属性! 。。。转载地址:http://hqyen.baihongyu.com/