首页 > 代码库 > Spring注解

Spring注解

一、常用注解

@RequestMapping 匹配路径

@PathVariable(value="http://www.mamicode.com/id")

@RequestParam(value="http://www.mamicode.com/name")  @RequestParam(value="http://www.mamicode.com/age",required=false,defaultValue="http://www.mamicode.com/0")

@CookieValue("JSESSIONID")

二、

REST风格增删改查

@RequestMapping(value="http://www.mamicode.com/addUser",RequestMethod.POST)

<form action="springmvc/addUser" method="post">

  <input type="text" name="uname" id="uname"/>

     <input type="submit" value="http://www.mamicode.com/提交"/>

</form>

@RequestMapping(value="http://www.mamicode.com/delUser",RequestMethod.DELETE)

<form action="springmvc/delUser" method="post">

  <input type="hidden" name="_method" id="DELETE"/>

     <input type="submit" value="http://www.mamicode.com/提交"/>

</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>

 

Spring注解