标签:
一、常用注解
@RequestMapping 匹配路径
@PathVariable(value="id")
@RequestParam(value="name") @RequestParam(value="age",required=false,defaultValue="0")
@CookieValue("JSESSIONID")
二、
REST风格增删改查
@RequestMapping(value="/addUser",RequestMethod.POST)
<form action="springmvc/addUser" method="post">
<input type="text" name="uname" id="uname"/>
<input type="submit" value="提交"/>
</form>
@RequestMapping(value="/delUser",RequestMethod.DELETE)
<form action="springmvc/delUser" method="post">
<input type="hidden" name="_method" id="DELETE"/>
<input type="submit" value="提交"/>
</form>
配置web.xml
<filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
标签:
原文地址:http://www.cnblogs.com/wangwanchao/p/5814403.html