【问题标题】:How handle resources likes images, *.css with Spring Mvc如何使用 Spring Mvc 处理图像、* .css 等资源
【发布时间】:2011-10-04 17:47:43
【问题描述】:

我在处理静态资源时遇到了问题。 这是我的网络应用程序 WebAppRoot -资源 -css -style.css -imahes -jsp -template.jsp -安全的 -template_secure.jsp 所以 我的位置=资源

如何以集中方式处理资源,例如,我将位置放在变量中,然后 在标签中使用它

我试过了,但我不明白如何使用。

【问题讨论】:

    标签: spring model-view-controller resources static


    【解决方案1】:

    如果您使用的是 Spring 3.0.4 或更高版本,则可以在应用程序配置中使用 < mvc:resources ...> 元素,而无需创建 Controller 来为您处理静态内容。

    就像指定静态内容的位置以及访问它们的路径一样简单:

    <mvc:resources mapping="/resources/**" location="/public-resources/"/>
    

    这使用找到的 mvc 命名空间 http://static.springsource.org/schema/mvc/spring-mvc.xsd

    【讨论】:

      猜你喜欢
      • 2014-12-04
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多