2013-01-22 116 views
1

我正在設置一個webapp,我試圖用Groovy代替Java。我有基本的設置,webapp啓動。到目前爲止,我有一個具有適當註釋的Controller。在啓動過程中,RequestMappings被映射,但是當我嘗試訪問映射時,webapp使用404來回答。使用Groovy的Spring MVC控制器

我見過this post,但它沒有解決我的問題(既不使用接口也不使用PostProcessor)。

下面是從應用程序啓動的日誌,我看不到任何東西,看起來很奇怪:

17:16:10.231 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started 
17:16:10.235 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 22 17:16:10 CET 2013]; root of context hierarchy 
17:16:10.296 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class de.rpr.query.config.AppConfig] 
17:16:10.902 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.s[email protected]7d21c8c4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,appConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,queryController,delegatingWebMvcConfiguration,requestMappingHandlerMapping,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,webConfig,jacksonObjectMapper,jacksonMessageConverter,viewResolver,groovyObjectPostProcessor]; root of factory hierarchy 
17:16:11.060 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/query/show],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object de.rpr.query.controller.QueryController.showQueryForm() 
17:16:11.124 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 
17:16:11.638 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1403 ms 
17:16:11.649 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started 
17:16:11.656 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Jan 22 17:16:11 CET 2013]; parent: Root WebApplicationContext 
17:16:11.660 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class de.rpr.query.config.WebConfig] 
17:16:11.701 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.s[email protected]35d0be7c: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,webConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,delegatingWebMvcConfiguration,requestMappingHandlerMapping,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,jacksonObjectMapper,jacksonMessageConverter,viewResolver]; parent: org.s[email protected]7d21c8c4 
17:16:11.829 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 
17:16:11.971 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 322 ms 

這是控制器:

@Controller 
@RequestMapping("/mapping") 
class QueryController { 

    @RequestMapping("/show") 
    def show() { 
     return "show"; 
    } 
} 

我缺少的東西,或做錯了什麼?幫助是非常appriciated!

+0

如果你從頭開始,爲什麼不使用Grails?這正是基於春季Groovy的網絡應用程序。 – vector

+0

根據日誌,你有一個名爲'QueryController'的控制器,其中一個映射到'/ query/show'的方法是'showQueryForm'。這個映射是否工作?這是一個Java控制器嗎? – ataylor

+0

@ataylor:控制器被命名爲QueryController,我更新了問題。該映射不起作用。 –

回答

2

見鬼,檢查了這一點,第2點下來:使用Groovy 2

配置和實現Spring的風格的應用程序: 基於Groovy的bean定義; Groovy中作爲首選從NEXT STOP: SPRING FRAMEWORK 4.0

的語言對整個應用

所以,你可能只是點點超前的時間在這裏:-)。但是你可能已經知道了。