2015-04-01 19 views
1

我想用<mvc:resource/><mvc:resources mapping="/images/**" location="/images/" /><mvc:resources mapping="/resources/**" location="/resources/" />context-mvc.groovy,我不知道該怎麼write.help我〜如何使用<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" 
    } 
} 

回答

0

爲了使用mvc命名空間在您的Groovy中,您需要將其添加到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/") 
} 
+0

謝謝你回答我的問題,我是春天的學習者,有時我覺得很難,感謝這些熱心的人,尤其是身邊,我還有一個問題,我的DipatcherServlet 是「/」,然後當我usemvc .resources(mapping:「/ images/**」,location:「/ images /」),我的viewResolver不起作用 – yang 2015-04-03 01:59:40

+0

import org.springframework.web.servlet.view.InternalResourceViewResolver beans { \t xmlns([context :「http://www.springframework.org/schema/context」, \t mvc:「http://www.springframework.org/schema/mvc」]) \t mvc.resources(mapping: 「/ images/**」,位置:「/ images /」) \t mvc.resources(mapping:「/ css/**」,location:「/ css /」) \t context「component-scan」( 「基本封裝」: 「com.oberon.fm」) \t視圖解析器(的InternalResourceViewResolver){ \t \t前綴= 「/頁/」 \t \t後綴= 「.JSP」 \t} } – yang 2015-04-03 02:08:31

相關問題