试图制作一些弹簧示例程序 – 不断得到错误 – 发生我的控制器无法处理/你好请求.这是来自log4j的调试信息.
13:50:58,502 {TRACE} DispatcherServlet.initContextHolders:1018 - Bound request context to thread: org.apache.catalina.connector.RequestFacade@636f2067
13:50:58,503 {DEBUG} DispatcherServlet.doService:823 - DispatcherServlet with name 'springtest' processing GET request for [/springtest_2/hello]
13:50:58,504 {TRACE} DispatcherServlet.getHandler:1088 - Testing handler map
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@7bab2c3] in DispatcherServlet with name 'springtest'
13:50:58,504 {DEBUG} RequestMappingHandlerMapping.getHandlerInternal:220 - Looking
up handler method for path /hello
13:50:58,504 {DEBUG} RequestMappingHandlerMapping.getHandlerInternal:230 - Did not find handler method for [/hello]
13:50:58,504 {TRACE} DispatcherServlet.getHandler:1088 - Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@722e242b] in DispatcherServlet with name 'springtest'
13:50:58,505 {TRACE} BeanNameUrlHandlerMapping.getHandlerInternal:127 - No handler mapping found for [/hello]
13:50:58,505 {WARN} PageNotFound.noHandlerFound:1108 - No mapping found for HTTP request with URI [/springtest_2/hello] in DispatcherServlet with name 'springtest'
13:50:58,505 {TRACE} DispatcherServlet.resetContextHolders:1028 - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@636f2067
13:50:58,505 {DEBUG} DispatcherServlet.processRequest:966 - Successfully completed request
13:50:58,506 {TRACE} XmlWebApplicationContext.publishEvent:332 - Publishing event in WebApplicationContext for namespace 'springtest-servlet': ServletRequestHandledEvent: url=[/springtest_2/hello]; client=[0:0:0:0:0:0:0:1]; method=[GET]; servlet=[springtest]; session=[null]; user=[null]; time=[9ms]; status=[OK]
我项目中的web.xml.
spring-test-servlet.xml – 我项目中的调度程序文件
ControllerMain.java – 来自我的项目
package com.denmroot.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
public class ControllerMain {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String helloworld (ModelMap model) {
model.addAttribute("message","Hello World !!! Spring Output");
return "hello";
}
}
最佳答案
原文链接:https://www.f2er.com/spring/432339.html