0
請查看我的控制檯中記錄的第一行和最後一行。 第一行聲明/SpringMVC/welcome映射到helloController但日誌中的最後一行顯示否則!SpringMVC:找不到HTTP請求的映射
背景:我從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'
控制器代碼:
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";
}
}
由於一噸......這有助於! – CBT
因此,您將原始控制器代碼從mykong更改爲@RequestMapping(「/ welcome」)更改爲@RequestMapping(「/ SpringMVC/welcome」)... – vzamanillo