The origin server did not find a current representation for the target resource解决方案

时间:2024-03-14 09:16:13

问题描述
tomcat9.0.6启动后可以进入初始页面,可以访问jsp但是action提交后出现报错:404
The origin server did not find a current representation for the target resource解决方案The origin server did not find a current representation for the target resource解决方案
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
控制台警告:org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping for POST /userinfo/login
解决方案:

web.xml添加
<servlet>
  <servlet-name>dispatcherServlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:dispatcherServlet-servlet.xml</param-value>
  </init-param>

  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>dispatcherServlet</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

2.检查资源包

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>javax.servlet-api</artifactId>

<version>3.1.0</version>

<scope>provided</scope>

</dependency>

3.idea 下路径 main后得package起始不要用com