码迷,mamicode.com
首页 > 编程语言 > 详细

Spring注解

时间:2016-08-28 10:58:36      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

一、常用注解

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

 

Spring注解

标签:

原文地址:http://www.cnblogs.com/wangwanchao/p/5814403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!