带有占位符的URL映射
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
凝一眸碧水,拈一缕清风,于一怀静谧中倾听凡尘的落音。
不再奢求什么,做简单的自己,过简单的生活,心在,梦在,你在,便是光阴赐予我的最美。