在我的上下文文件中,我想添加一行以便能够访问静态内容。直到我添加它,一切正常,但添加后,我不能访问有一些控制器的页面,我得到这个警告:WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/fit/] in DispatcherServlet with name 'mvc-dispatcher'
。加入<mvc:resources mapping="/resources/**" location="/resources/" />
上下文文件之前,它看起来像这样:执行资源映射后,Spring MVC映射不起作用
<?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>
任何想法如何解决这一问题? PS:这些页面用Spring安全保护,但我不认为这可能是问题。
请张贴您的Web.xml和一个Jsp和控制器also.I wana检查您如何映射传入的请求以及如何使用您的JSP页面中的静态内容。 – beinghuman 2013-09-09 12:20:02
哦..这个话题在这一刻并不是真的,问题解决了。我会用代码发布答案。感谢提醒:] – Dworza 2013-09-09 14:45:57
解决方案是什么?我没有找到你说的答案:( – 2016-06-09 18:46:52