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/views
that Dept
I modified the directory name after creating a subdirectory dept
, but because it has been run through IntelliJ Idea
the configuration in the tomcat
previous, it still exists in the project target/demo/WEB-INF/views
directory Dept
, and finally caused the above error. Finally delete that directory, recreate the dept
directory and run the project .