我刚开始使用spring框架,我的spring bean配置有问题。
要加载我的静态资源,如css,js等,我必须输入以下行:
我的spring bean配置中的<mvc:resources mapping=”/resources/**” location=”/resources/” />
:
我的问题是,如果我把这行,由于某种原因,我部署我的应用程序时,我的应用程序的所有url都没有映射。当我评论这一行时,所有url的应用程序都运行正常,但当然我的静态资源没有映射。
我需要一些关于如何解决这个问题的提示。谢谢 !。 这也是我的spring-config.xml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<context:component-scan base-package="com.application" />
<!-- Mapping the static resources -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- Unimportant for my problem -->
<!-- Bean used for login from userDao(repository) -->
<bean id="customUserDetailsService" class="com.application.service.CustomUserDetailsService"></bean>
<!-- Setup the userDao(repository) -->
<bean id="userDao" class="com.application.model.UserDAO" />
<!-- Declared datasource bean -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/licenta" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
</beans>