[英]Spring MVC mapping doesn't work after resources mapping implemented
In my context file I want to add line to be able to access static content. 我想在上下文文件中添加一行以访问静态内容。 Until I add it, everything works allright, but after I add it, I can't access pages that have some controller and I get this warning:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/fit/] in DispatcherServlet with name 'mvc-dispatcher'
. 在添加它之前,一切正常,但是添加后,我将无法访问具有某些控制器的页面,并且收到以下警告:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/fit/] in DispatcherServlet with name 'mvc-dispatcher'
。 Before adding <mvc:resources mapping="/resources/**" location="/resources/" />
to context file, it looks like this: 在将
<mvc:resources mapping="/resources/**" location="/resources/" />
到上下文文件之前,它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<context:annotation-config />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<context:component-scan base-package="cz.cvut.fit.genepi.controllers" />
<import resource="classpath:applicationContext-security.xml" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
</beans>
Any idea how to fix this? 任何想法如何解决这个问题?
PS:those pages are secured with Spring security, but I don't think that this could be the problem. PS:这些页面都具有Spring安全性,但是我认为这可能不是问题。
Every dispatcher servlet ends with -servlet. 每个调度程序servlet以-servlet结尾。 Try renaming your dispatcher servlet.
尝试重命名调度程序servlet。
On initialization of a DispatcherServlet, the framework will look for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and create the beans defined there. 在初始化DispatcherServlet时,框架将在Web应用程序的WEB-INF目录中查找名为[servlet-name] -servlet.xml的文件,并在此处定义定义的bean。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.