<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>login</title>
</head>
<body>
<form action="login" method="get">
账号:<input type="text" name="username"><br>
密码:<input type="password" name="password"><br>
爱好:<input type="checkbox" name="aihao" value="lq">篮球
<input type="checkbox" name="aihao" value="zq">足球
<input type="checkbox" name="aihao" value="pq">排球
<input type="submit" value="登录">
</form>
</body>
</html>
以上是我自己的HTML表单提交方式,提交方式为get
在对应的Servlet中重写了service中的doGet与doPost 方法
@WebServlet(name = "login",urlPatterns = "/login")
public class LoginServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("do get method");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("do Post method");
}
}
最后执行却为Post方法
最后试了很多方法,找了环境变量问题,工件部署问题,都没解决,终于……清除浏览器缓存之后问题完美解决!!!!