package com.zhangpn.hello; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class Hello { @RequestMapping(value="/hello/{id}",method=RequestMethod.GET) public String Hello(@PathVariable(value="id") int id) { System.out.println("**************hello*******************"+id); return "success"; } }
http://localhost:8080/SpringMVC/hello/45
id就被赋值为45