//@PathVariable能夠用來映射URL中的佔位符到目標方法的參數中 @RequestMapping("/testPathVariable/{id}") public String testPathVariable(@PathVariable("id") Integer id){ System.out.println("testPathVariable:"+id); return SUCCESS; }
@RequestMapping("/user") @ResponseBody public String getUserBlog(@RequestParam("id") int blogId) { return "blogId = " + blogId; }
@RequestMapping("/user") @ResponseBody public String getUserBlog(@RequestParam(value="id",require=false,default='0') int blogId) { return "blogId = " + blogId; }