404-在jsp

时间:2018-11-05 11:22:41

标签: jsp servlets

单击以下jsp文件中的链接时出现404错误 这是我的jsp文件。

错误:/ list(也适用于/ new)

说明:原始服务器未找到目标资源的当前表示,或不愿意透露其存在。

    <h1>Books Management</h1>
    <h2>
        <a href="/new">Add New Book</a>
        &nbsp;&nbsp;&nbsp;
        <a href="/list">List All Books</a>

    </h2>

这是我的servlet ...

   @WebServlet("/")
   public class Controller extends HttpServlet {
      private static final long serialVersionUID = 1L;
      private DataCrud bookDAO=new DataCrud();

   protected void doGet(HttpServletRequest request, HttpServletResponse 
     response) throws ServletException, IOException {
     String action = request.getServletPath();

        try {
            switch (action) {
            case "/new":
                showNewForm(request, response);
                break;
            case "/insert":
                insertBook(request, response);
                break;
            case "/delete":
                deleteBook(request, response);
                break;
            case "/edit":
                showEditForm(request, response);
                break;
            case "/update":
                updateBook(request, response);
                break;
            default:
                listBook(request, response);
                break;
            }
        } catch (SQLException ex) {
            throw new ServletException(ex);
        }
}

0 个答案:

没有答案