如何在Groovy中使用<mvc:resource> </mvc:resource>

时间:2015-04-01 02:59:13

标签: spring spring-mvc groovy gradle

我想在<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"
    }
}

1 个答案:

答案 0 :(得分:0)

为了在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/")
}