gpt4 book ai didi

java - 基于 Spring mvc 注解的 Controller RequestMappingHandlerMapping 有什么问题?

转载 作者:行者123 更新时间:2023-11-30 09:23:18 24 4
gpt4 key购买 nike

我正在将我的一个应用程序从 Spring 工具套件 IDE 移植到纯 Eclipse Java EE IDE。在这个过程中,我正在重命名一些包并更改为基于 Maven。然后所有 Controller 都不再工作。

我认为注释 Controller 发现似乎已损坏。没有映射 url 注册到 Spring。

有人知道问题出在哪里吗?

我从我的 STS(工作)中收集旧日志,它工作正常并且喜欢

> 2013-04-21 22:43:05,622 [Thread-1] DEBUG
> org.springframework.beans.factory.support.DefaultListableBeanFactory -
> Finished creating instance of bean
> 'org.springframework.web.servlet.handler.MappedInterceptor#2'
> 2013-04-21 22:43:05,623 [Thread-1] DEBUG
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
> - Looking for request mappings in application context: WebApplicationContext for namespace 'HelloSpringroo2-servlet': startup
> date [Sun Apr 21 22:43:05 EDT 2013]; parent: Root
> WebApplicationContext 2013-04-21 22:43:05,653 [Thread-1] INFO
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
> - Mapped "{[/account/create],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
> onto public java.lang.String
> com.hellospringroo.controllers.AccountController.createAccountActionDisplay(org.springframework.ui.Model)
> 2013-04-21 22:43:05,653 [Thread-1] INFO
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
> - Mapped "{[/account/view/{account_Id}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
> onto public java.lang.String
> com.hellospringroo.controllers.AccountController.viewAccountActionDisplay(int,org.springframework.ui.Model)
> throws java.lang.Exception

然后我从Eclipse中收集日志(问题一)

> 2013-04-21 22:48:04,900 [http-bio-8080-exec-3] DEBUG
> org.springframework.web.servlet.DispatcherServlet - DispatcherServlet
> with name 'Education' processing GET request for [/Education/]
> 2013-04-21 22:48:04,901 [http-bio-8080-exec-3] DEBUG
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
> - Looking up handler method for path / 2013-04-21 22:48:04,901 [http-bio-8080-exec-3] DEBUG
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
> - Did not find handler method for [/] 2013-04-21 22:48:04,904 [http-bio-8080-exec-3] DEBUG
> org.springframework.web.servlet.handler.SimpleUrlHandlerMapping -
> Mapping [/] to HandlerExecutionChain with handler
> [org.springframework.web.servlet.mvc.ParameterizableViewController@54bbb2d0]
> and 1 interceptor 2013-04-21 22:48:04,905 [http-bio-8080-exec-3] DEBUG
> org.springframework.web.servlet.DispatcherServlet - Last-Modified
> value for [/Education/] is: -1 2013-04-21 22:48:04,914
> [http-bio-8080-exec-3] DEBUG
> org.springframework.beans.factory.support.DefaultListableBeanFactory -
> Invoking afterPropertiesSet() on bean with name 'index'

最佳答案

你的:

<context:component-scan base-package="old.package.name" />

现在应该是

<context:component-scan base-package="new.package.name" />

关于java - 基于 Spring mvc 注解的 Controller RequestMappingHandlerMapping 有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16139008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com