我想在<mvc:resource/>
中使用<mvc:resources mapping="/images/**" location="/images/" />
,例如<mvc:resources mapping="/resources/**" location="/resources/" />
context-mvc.groovy
,但我不知道该怎么写。帮帮我〜
import org.springframework.web.servlet.view.InternalResourceViewResolver
beans {
xmlns context: "http://www.springframework.org/schema/context"
context."component-scan"("base-package" : "com.oberon.fm")
viewResolver(InternalResourceViewResolver) {
prefix = "/pages/"
suffix = ".jsp"
}
}
最佳答案
为了在Groovy中使用mvc命名空间,您需要将其添加到xmlns
。
然后,您可以像使用上下文一样使用它。
beans {
xmlns([ctx:'http://www.springframework.org/schema/context',
mvc:'http://www.springframework.org/schema/mvc'])
ctx.'component-scan'('base-package': "com.oberon.fm")
mvc.resources(mapping:"/images/**", location:"/images/")
mvc.resources(mapping:"/resources/**", location:"/resources/")
}
关于spring - 如何在Groovy中使用<mvc:resource/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29382133/