get:/restUrl/{id}
post:/restUrl
delete:/restUrl/{id}
put:/restUrl
@RequestMapping(value="/restUrl/{id}", method=RequestMethod.GET)
public String get(Map<String, Object> map, @PathVariable("id") Integer id){
Object obj = new Object();
map.put("obj", obj);
return "success";
}
注意:
@RequestMapping(value="/restUrl", method=RequestMethod.POST)
public String post(Object obj){
System.out.println(obj);
return "success";
}
注意:
@RequestMapping(value="/restUrl/{id}", method=RequestMethod.DELETE)
public String delete(@PathVariable("id") Integerid){
System.out.println(id);
return "success";
}
注意:
@RequestMapping(value="/restUrl", method=RequestMethod.PUT)
public String put(Object obj){
System.out.println(obj);
return "success";
}
<a href="${pageContext.request.contextPath}/user/restUrl/{id}">get user</a>
注意:
<form action="${pageContext.request.contextPath }/restUrl" method="post" >
name:<input type="text" name="username"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>
注意:
<a class="delete_href" href="${pageContext.request.contextPath }/restUrl/{id}">remove</a>
<form id="delete_form" action="" method="post">
<input type="hidden" name="_method" value="DELETE">
</form>
$(function(){
$(".delete_href").on("click", function(){var href = $(this).attr("href");
$("#delete_form").attr("action", href).submit();
return false;
})
})
注意:
<form action="${pageContext.request.contextPath }/restUrl" method="post" >
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="id" value="${id }">
name:<input type="text" name="username"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>
注意: