这里是我的控制器类的代码:SPRING 3 MVC - URI模板错误?
package edu.byu.cio.test.web.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Handles requests for the application home page.
*/
@Controller
public class HomeController {
@RequestMapping(value = "/")
public String helloWorld() {
System.out.println("HomeController: Passing through...");
return "WEB-INF/views/home.jsp";
}
@RequestMapping(value="/name/{Name}", method = RequestMethod.GET)
public String compare(@PathVariable("Name") String Name) {
return "WEB-INF/views/home.jsp";
}
}
我感兴趣的调用第二种方法。
当我做GET请求为:
http://localhost:8081/mvc-basic/name/somename
注意:我已经配置它的端口监听8081
我得到以下错误:
HTTP Status 404 - /mvc-basic/name/WEB-INF/views/home.jsp
--------------------------------------------------------------------------------
type Status report
message /mvc-basic/name/WEB-INF/views/home.jsp
description The requested resource (/mvc-basic/name/WEB-INF/views/home.jsp) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.26
我认为URI模式是正确的,但我想知道为什么它会显示这个错误。你在上面的代码中找到任何错误吗?我感谢您的帮助。
现在格式化代码,给我们你的调度器 - 小服务程序配置,并删除多个问号。 – Bozho 2011-05-11 22:32:17