能正常访问index.jsp以及login.html,
但在点击登录后报404
<td id="right_cont">
<table height="100%">
<tr height="30%"><td colspan="3"> </td></tr>
<tr>
<td width="30%" rowspan="5"> </td>
<td valign="top" id="form">
<form id="fmLogin" method="post" action="user.let?type=login">
<table valign="top" width="50%">
<tr><td colspan="2"><h4 style="letter-spacing:1px;font-size:16px;">图书管理系统</h4></td></tr>
<tr><td>管理员:</td><td><input type="text" name="name" required /></td></tr>
<tr><td>密 码:</td><td><input type="password" name="pwd" required/></td></tr>
<!-- <tr><td>验证码:</td><td><input type="text" name="valcode" value="" style="width:80px;" required/> <img src="#"/></td></tr>-->
<tr class="bt"><td> </td><td><input type="submit" value="登录" /> <input type="reset" value="重填" /></td></tr>
</table>
</form>
</td>
<td rowspan="5"> </td>
</tr>
<tr><td colspan="3"> </td></tr>
</table>
</td>
@WebServlet( "/user.let")
public class UserServlet extends HttpServlet {
//构建Userbiz的对象
UserBiz userBiz=new UserBiz();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
resp.setContentType("text/html;charset=utf-8");
PrintWriter out=resp.getWriter();
System.out.println("123");
//判断用户请求类型为login
String method= req.getParameter("type");
switch (method){
case "login":
//获取用户名和密码
String name=req.getParameter("name");
String pwd=req.getParameter("pwd");
//调用UserBiz的getUser方法,获取对应对象
User user=userBiz.getUser(name,pwd);
//4判断对象是否为空
if(user==null){
//提示错误,返回登录页面
out.println("<script>alet('用户名或密码不存在');location.href='login.html'</script>");
}else{
//非空,跳转到index.jsp
out.println("<script>alet('登录成功');location.href='index.jsp'</script>");
}
break;
}
}
}
HTTP状态 404 - 未找到
类型 状态报告
消息 请求的资源[/mybook_war_exploded/user.let]不可用
描述 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。
Apache Tomcat/10.0.18