为了账号安全,请及时绑定邮箱和手机立即绑定

报错404,单独打开都可以打开,但是使用login跳转又没用,代码贴在下面了

报错:

HTTP Status 404 - /LoginFilter%3E/servlet/LoginServlet

type Status report

message /LoginFilter%3E/servlet/LoginServlet

description The requested resource is not available.

Apache Tomcat/7.0.65

我的LoginServlet.java里的代码:

package servlet;


import java.io.IOException;

import java.io.PrintWriter;


import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


public class LoginServlet extends HttpServlet {


/**

* Constructor of the object.

*/

public LoginServlet() {

super();

}


/**

* Destruction of the servlet. <br>

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}


/**

* The doGet method of the servlet. <br>

*

* This method is called when a form has its tag value method equals to get.

* @param request the request send by the client to the server

* @param response the response send by the server to the client

* @throws ServletException if an error occurred

* @throws IOException if an error occurred

*/

public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {


doPost(request,response);

}


/**

* The doPost method of the servlet. <br>

*

* This method is called when a form has its tag value method equals to post.

* @param request the request send by the client to the server

* @param response the response send by the server to the client

* @throws ServletException if an error occurred

* @throws IOException if an error occurred

*/

public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

//获取当前用户名和密码

String username = request.getParameter("username");

String password = request.getParameter("password");

if("admin".equals(username)&&"admin".equals(password)){

request.getSession().setAttribute("username", username);

response.sendRedirect(request.getContextPath()+"/success.jsp");

}else{

response.sendRedirect(request.getContextPath()+"/failure.jsp");

}

}


/**

* Initialization of the servlet. <br>

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}


}

望各位可以指点一下,找了半天的错没找到

正在回答

1 回答

可能是login.jsp里面 表单的 action的路径写错了

0 回复 有任何疑惑可以回复我~
#1

终有弱水替沧海4032800 提问者

还真是地址多打了>,谢谢啦
2016-11-20 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

报错404,单独打开都可以打开,但是使用login跳转又没用,代码贴在下面了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信