Spring Error Collection (2)

Development tools: IntelliJ idea
JDK: 8
Tomcat: 8.x

mistake

During the development of SpringMVC, /WEB-INF/views/the following error occurred when accessing the jsp files in multiple directories through URL requests:

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

config file (section)

web.xml

<!-- 配置DispatcherServlet -->
<servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:springMVC-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

springMVC-servlet.xml

 <!-- 开启注解 -->
 <mvc:annotation-driven/>
 <!--静态文件配置-->
 <mvc:default-servlet-handler />
 <!-- 设置组件扫描的基础包 -->
 <context:component-scan base-package="com.demo.controller"/>
<!-- 配置视图解析器 -->
<bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
   <property name="prefix" value="/WEB-INF/views/" />
   <property name="suffix" value=".jsp" />
</bean>

reason

This error is definitely not a configuration error. Later, I suddenly remembered /WEB-INF/viewsthat DeptI modified the directory name after creating a subdirectory dept, but because it has been run through IntelliJ Ideathe configuration in the tomcatprevious, it still exists in the project target/demo/WEB-INF/viewsdirectory Dept, and finally caused the above error. Finally delete that directory, recreate the deptdirectory and run the project .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324673863&siteId=291194637