Allen_Zsj

导航

表单传值给@Controller

<form action="springmvc/testModelAttributes" method="post">
<input type="hidden" name="id" value="1"/>
username:<input type="text" name="username" value="Tom"/>
<br><br>
email:<input type="text" name="email" value="tom@atguigu.com"/>
<br><br>
age:<input type="text" name="age" value="12"/>
<br><br>
city:<input type="text" name=privnce value="beijing"/>
<br><br>
<input type="submit" value="Submit"/>
</form>

 

@RequestMapping("/testModelAttributes")
public String testModelAttributes(User user){
System.out.println("修改user信息:" + user);
return SUCCESS;
}

 

User会取form表单name为自己属性的属性值存储

posted on 2018-01-08 14:50  Allen_Zsj  阅读(314)  评论(0编辑  收藏  举报