maven3.8.1
JDK11Tomcat9.0.97
修改apache-tomcat-9.0.97\conf\logging.properties文件:
@WebServlet("/login")
public class LoginServlet extends HttpServlet {@Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {req.setCharacterEncoding("UTF-8");String username = req.getParameter("username");String userPwd = req.getParameter("userPwd");System.out.println("用户名:" + username);System.out.println("密码:" + userPwd);resp.setContentType("text/html;charset=utf-8");PrintWriter writer = resp.getWriter();writer.write(username + "<h1>登录成功!</h1>");writer.close();}
}