springmvc静态资源配置

1、静态资源配置

  1. <mvc:default-servlet-handler/>   

2、完整配置

  1. <beans xmlns="http://www.springframework.org/schema/beans"  
  2.  xmlns:context="http://www.springframework.org/schema/context"  
  3.  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.  xmlns:mvc="http://www.springframework.org/schema/mvc"   
  5.  xsi:schemaLocation="  
  6. http://www.springframework.org/schema/beans  
  7. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8. http://www.springframework.org/schema/context  
  9. http://www.springframework.org/schema/context/spring-context-3.0.xsd  
  10. http://www.springframework.org/schema/mvc   
  11. http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">  
  12.  <context:component-scan base-package="com.nextgame.web" />  
  13.  <!--mvc静态资源访问 -->  
  14.  <mvc:default-servlet-handler/>   
  15.  <bean  
  16.  class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
  17.  <property name="prefix">  
  18.  <value>/WEB-INF/views/</value>  
  19.  </property>  
  20.  <property name="suffix">  
  21.  <value>.jsp</value>  
  22.  </property>  
  23.  </bean>  
  24. </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目录下,可自定义子目录。

5、浏览器访问静态图片

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值