新建login.jsp和LoginServlet.java
浏览器默认的GET方法地址栏显示如下:
http://localhost:8080/test/LoginServlet?username=123&password=123
在login.jsp表单修改成post方法
<form action="/test/LoginServlet"method="post">
同时还要修改LoginServlet.java内容重写doPost()方法
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("doPost invoked!");
process(req,resp);
}
在doGet()选中方法体refactor->extract method ->name:process
重启Tomcat
浏览器使用POST方法返回地址栏内容变成http://localhost:8080/test/LoginServlet