gpt4 book ai didi

java - SpringMVC : No mapping found for HTTP request

转载 作者:行者123 更新时间:2023-12-01 12:47:37 24 4
gpt4 key购买 nike

请查看我的控制台中记录的第一行和最后一行。第一行声明 /SpringMVC/welcome 映射到 helloController 但日志中的最后一行显示其他情况!

背景:我直接从 MyKong 获取源代码并试图逃跑。除了将 @RequestMapping("/welcome") 更改为 @RequestMapping("/SpringMVC/welcome") 之外,我没有更改任何配置。提供完整源代码here

INFO: Mapped URL path [/SpringMVC/welcome] onto handler 'helloController'
Jul 2, 2014 8:17:54 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/SpringMVC/welcome.*] onto handler 'helloController'
Jul 2, 2014 8:17:54 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/SpringMVC/welcome/] onto handler 'helloController'
Jul 2, 2014 8:17:54 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'mvc-dispatcher': initialization completed in 231 ms
Jul 2, 2014 8:17:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 2, 2014 8:17:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 2, 2014 8:17:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2249 ms
Jul 2, 2014 8:17:55 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jul 2, 2014 8:18:03 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/welcome] in DispatcherServlet with name 'mvc-dispatcher'

Controller 代码:

package com.mkyong.common.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/SpringMVC/welcome")
public class HelloController {

@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {

model.addAttribute("message", "Spring 3 MVC Hello World");
return "hello";

}

}

最佳答案

是的。您的 Controller 方法已映射到

/SpringMVC/welcome

相对于您的上下文路径。

也就是说,如果您的上下文路径是

/SpringMVC

,那么请求需要发送到

/SpringMVC/SpringMVC/welcome

关于java - SpringMVC : No mapping found for HTTP request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24534908/

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