我正在关注本教程here
复制和过去的确切代码,更改了servlet的名称以及web.xml中的映射,但是当我尝试登录(作为“admin”,存在于mysql数据库中)时,我得到一个带有以下url的空白页:
http://localhost:8080/project6/LoginServdo?username=admin&password=admin
没有任何反应,如果有人在此之前解决了这个问题,请提前感谢你。
答案 0 :(得分:1)
如果您在doGet()
或doPost()
结束时没有向浏览器发回任何内容,那么您将获得一个空白页。
在doPost()
之后,通常会发送重定向,执行类似
response.sendRedirect("/loggedin");
/loggedin
处理程序发出HTML。
答案 1 :(得分:0)
如果您的网址如此,那么您的表单方法可能不是发布。所以检查一下,它应该是:
<form action="servlet1" method="post">
或者您可以将其添加到WelcomeServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}