当前位置: 代码迷 >> 综合 >> Tomcat 404 error: The origin server did not find a current representation for the target resource or
  详细解决方案

Tomcat 404 error: The origin server did not find a current representation for the target resource or

热度:71   发布时间:2023-10-27 16:05:01.0

之前写了一个web项目,后面需要对这个项目进行小小的修改,但是又想保留原来的项目。这个时候,我新建了一个web项目,然后把之前项目所需的jar包、三层+Servlet、jsp页面全都复制到新的项目中,启动tomcat之后,请求servlet的时候就抛出了这样的异常。

解决方式:把原来项目的web.xml文件打开,把关于servlet的配置信息全部复制到你新建项目的web.xml中。我的如下

  <servlet><servlet-name>CustomerServlet</servlet-name><servlet-class>CRM.Servlet.CustomerServlet</servlet-class></servlet><servlet><servlet-name>FindAllServlet</servlet-name><servlet-class>CRM.Servlet.FindAllServlet</servlet-class></servlet><servlet><servlet-name>EditServlet</servlet-name><servlet-class>CRM.Servlet.EditServlet</servlet-class></servlet><servlet><servlet-name>SaveEditServlet</servlet-name><servlet-class>CRM.Servlet.SaveEditServlet</servlet-class></servlet><servlet><servlet-name>DeleteServlet</servlet-name><servlet-class>CRM.Servlet.DeleteServlet</servlet-class></servlet><servlet><servlet-name>SouServlet</servlet-name><servlet-class>CRM.Servlet.SouServlet</servlet-class></servlet><servlet-mapping><servlet-name>CustomerServlet</servlet-name><url-pattern>/CustomerServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>FindAllServlet</servlet-name><url-pattern>/FindAllServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>EditServlet</servlet-name><url-pattern>/EditServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>SaveEditServlet</servlet-name><url-pattern>/SaveEditServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>DeleteServlet</servlet-name><url-pattern>/DeleteServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>SouServlet</servlet-name><url-pattern>/SouServlet</url-pattern></servlet-mapping>

完成后重启tomcat,重新请求servlet,就不会有异常了。

  相关解决方案