1、静态资源配置
- <mvc:default-servlet-handler/>
2、完整配置
- <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-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/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
- <context:component-scan base-package="com.nextgame.web" />
- <!--mvc静态资源访问 -->
- <mvc:default-servlet-handler/>
- <bean
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix">
- <value>/WEB-INF/views/</value>
- </property>
- <property name="suffix">
- <value>.jsp</value>
- </property>
- </bean>
- </beans>
3、问题
the prefix "mvc" for element "mvc:default-servlet-handler" is not bound
在xml的beans中添加
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
4、静态资源存放位置
静态资源存放在工程中的webapp目录下,可自定义子目录。