网站的弹窗广告怎么做,东莞饭堂承包东莞网站建设,展馆在线设计平台,宝塔虚拟主机一、 在HTTP 协议里面#xff0c;四个表示操作方式的动词#xff1a;GET、POST、PUT、DELETE。它们分别对应四种基本操作#xff1a;1、GET 获 取资源2、POST 新建资源3、PUT 更新资源4、DELETE 删除资源二、REST#xff1a;即 Representational State Transfer。(资源)表…一、 在HTTP 协议里面四个表示操作方式的动词GET、POST、PUT、DELETE。它们分别对应四种基本操作1、GET 获 取资源2、POST 新建资源3、PUT 更新资源4、DELETE 删除资源二、REST即 Representational State Transfer。(资源)表现层状态转化。是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、扩展方便 所以正得到越来越多网站的采用。我们可以通过rest风格占位符方式利用PathVariable注解将占位符的值赋给调用方法参数实现结果/某路径/1 HTTP GET 得到 id 1 的 一条数据/某路径/1 HTTP DELETE 删除 id 1的 一条数据/某路径/1 HTTP PUT 更新id 1的 一条数据/某路径 HTTP POST 新增一条数据实现方式(REST风格四种请求方式的调用)我们通过RequestMapping映射请求中的method参数实现四种请求方式的调用以下为示例代码。GET请求RequestMapping(value/student,methodRequestMethod.GET)public ModelAndView toAddPage(){ModelAndView mViewnew ModelAndView();mView.addObject(employee,new Employee());mView.setViewName(add-stu);mView.addObject(departments, departmentDao.getDepartments());return mView;}POST请求RequestMapping(value/student,methodRequestMethod.POST)public String addStu(Employee employee){employeeDao.save(employee);return redirect:/show ;}DELETE请求RequestMapping(value/student/{id},methodRequestMethod.DELETE)public String deleteStu(PathVariable(valueid) Integer id){employeeDao.delete(id);return redirect:/show ;}PUT请求RequestMapping(value/student,methodRequestMethod.PUT)public String Update(RequestParam(valueid)Integer id,Employee employee){employeeDao.save(employee);return redirect:/show ;}三、将POST请求转化为put请求和delele请求1.在web.xml文件中配置HiddenHttpMethodFilter过滤器hiddenHttpMethodFilterorg.springframework.web.filter.HiddenHttpMethodFilterhiddenHttpMethodFilter/*2.在表单域中需要携带一个name值为_methodvalue值为put或者delete的参数如下所示姓名姓名邮箱Mapmapnew HashMap();map.put(1,Male);map.put(0, Female);request.setAttribute(genders, map);%性别部门最后在Controller层调用即可。根据RequestMapping的value值以及携带的参数、请求方式查找匹配函数。以上这篇SpringMVC的REST风格的四种请求方式总结就是小编分享给大家的全部内容了希望能给大家一个参考也希望大家多多支持我们。时间 2017-08-28