一、:
<a href="SpringMVCController/welcome">first springmvc</a>
可以通过映射:
@RequestMapping("welcome") public String welcome(){ return "success"; }
<form action="SpringMVCController/welcome" method="post"> name:<input name="name"><br/> age:<input name="age"> <input type="submit" value="确定"> </form>
可以通过映射:
@RequestMapping(value="welcome",method=RequestMethod.POST,params={"name=zs","age!=23","!height"}) public String welcome(){ return "success"; }
!height表示前台jsp中的input标签不能有height。
<a href="SpringMVCController/welcome2">first springmvc</a>
可以通过映射:
@RequestMapping(value="welcome2",headers={"Accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","Accept-Encoding=gzip, deflate, br"}) public String welcome2(){ return "success"; }
传值:
<a href="SpringMVCController/welcome4/zs">first springmvc</a>
@RequestMapping(value="welcome4/{name}") public String welcome4(@PathVariable("name") String name){ System.out.println(name); return "success"; }
输出“zs”