1

我正在设置一个 web 应用程序,我正在尝试使用 Groovy 而不是 Java。我有基本设置,webapp 启动。到目前为止,我有一个带有适当注释的控制器。在启动期间,RequestMappings 被映射,但是当我尝试访问映射时,webapp 以 404 回答。

我看过这篇文章,但它并没有解决我的问题(既不使用接口也不使用 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.springframework.beans.factory.support.DefaultListableBeanFactory@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.springframework.beans.factory.support.DefaultListableBeanFactory@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.springframework.beans.factory.support.DefaultListableBeanFactory@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";
    }
}

我错过了什么或做错了什么?非常感谢您的帮助!

4

1 回答 1

2

到底是什么,检查一下,第二个子弹:

使用 Groovy 2 配置和实现 Spring 风格的应用程序:基于 Groovy 的 bean 定义;Groovy 作为整个应用程序的首选语言

下一站开始:春季框架 4.0

所以你在这里可能只是提前一点点:-)。但你可能已经知道了。

于 2013-01-22T18:09:50.817 回答