spring - 为什么资源文件没有在spring-mvc中加载
问题描述
我在 servlet.xml 中添加了 mvc:resource 标记,但我的应用程序没有获取任何资源文件。我正在尝试开发基于 xml 的 spring mvc 应用程序。为什么资源文件没有加载?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean name="/welcome.htm"
class="com.debasish.common.controller.HelloWorldController" />
<mvc:resources location="/resources/" mapping="/test/**"></mvc:resources>
<mvc:annotation-driven></mvc:annotation-driven>
</beans>
解决方案
如前所述,尝试像这样更改映射和位置的顺序
<mvc:resources mapping="/client/**" location="/optimized-scripts/visualize/" />
<mvc:annotation-driven />
推荐阅读
- amazon-web-services - 如何对 AWS S3 存储桶访问进行速率限制
- java - 在多线程环境中迭代集合:ConcurrentModificationException
- email-validation - 这是一个有效的电子邮件“john.doe@hello.example.com”吗?
- angular - 没有使用 pptxGenjs 库在 angular5 中获取数据流
- c# - MVVM 与模型中的集合绑定
- rest - 访问后端地理数据库
- c - 如何一次读取所有 CPU 内核的频率?
- java - 如何从 Kafka Producer 返回具有数十亿条记录的 ArrayList?
- php - Wordpress - 如何将类别页面更改为完整列表视图?
- c# - 如何仅在 VSTO 应用程序之上制作 WPF 窗口?