這裏是我的控制器類的代碼: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