有人可以幫我解決這個問題。我是新來的春天所以..在這種情況下,問題是 url =「localhost:8080/projectname/stuff」一切工作正常資源被導入,但當我添加「/」或任何@pathVariable「/ stuff/{id }」,ressources不再進口,所以我沒有像無CSS什麼春季資源映射mvc 3
爲spring-servlet.xml
<import resource="data-config.xml"/>
<mvc:resources mapping="/assets/**" location="/WEB-INF/assets/" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="classpath:/META-INF/spring/jdbc.properties" />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="persistenceUnitName" value="persistence" />
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
<context:annotation-config />
<mvc:default-servlet-handler/>
<context:component-scan base-package="com.bd" annotation-config="true" />
<mvc:annotation-driven />
<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/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
</beans>
彈簧security.xml文件
<http pattern="/login" security="none"/>
<http pattern="/assets/**" security="none"/>
<http auto-config="true" use-expressions="true">
<access-denied-handler error-page="/denied" />
<intercept-url pattern="/login" access="permitAll"></intercept-url>
<intercept-url pattern="/logout" access="permitAll"></intercept-url>
<intercept-url pattern="/" access="isAnonymous()"></intercept-url>
<intercept-url pattern="/admin*" access="isAuthenticated()"/>
<intercept-url pattern="/admin/*" access="isAuthenticated()"/>
<form-login login-page="/login" default-target-url="/admin/question" authentication-failure-url="/login"
username-parameter="username"
password-parameter="password"
/>
<logout logout-success-url="/login?logout" invalidate-session="true" delete-cookies="JSESSIONID"/>
</http>
<beans:bean id="userDetailsService" class="com.bd.service.implement.UserDetailsServiceImpl"></beans:bean>
<authentication-manager>
<authentication-provider user-service-ref="userDetailsService">
<password-encoder hash="md5"/>
</authentication-provider>
</authentication-manager>
</beans:beans>
@ user3786833你會把它標記爲答案嗎? –