404 - 未找到错误 RequestDispatcher jsp 转发

404 - Not Found Error RequestDispatcher jsp forward

我正在尝试将 Servlet 转发到 JSP,但当我单击调用转发到 JSP

的 doGet() 的按钮时出现此错误

Type Status Report

Message /servlet/crossfit/WOD

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

这是我的 Servlet 代码:

RequestDispatcher rd getServletContext().getRequestDispatcher("/app/crossfit/amrap.jsp");
        rd.forward(request, response);

这是我的 web.xml 文件中的映射

 <servlet>
    <servlet-name>WOD</servlet-name>
    <description>Handle the workout generator and saver</description>
    <servlet-class>servlet.activity.crossfit.WOD</servlet-class>
</servlet>
  <servlet-mapping>
    <servlet-name>WOD</servlet-name>
    <url-pattern>/servlet/activity/crossfit/WOD</url-pattern>
</servlet-mapping>

> <servlet-mapping>
>         <servlet-name>AmrapServlet</servlet-name>
>         <url-pattern>/app/crossfit/amrap.jsp</url-pattern>
> </servlet-mapping>


> <servlet>
>     <servlet-name>AmrapServlet</servlet-name>
>     <jsp-file>/app/crossfit/amrap.jsp</jsp-file> </servlet>

Project Structure

请求中缺少路径 activity。请求的路径是 /servlet/crossfit/WOD 并且在你的 web.xml 中你有 /servlet/activity/crossfit/WOD

在你有按钮的代码中调整你的请求路径从 /servlet/crossfit/WOD/servlet/activity/crossfit/WOD