zoukankan      html  css  js  c++  java
  • Spring MVC RESTful

    REST:

    即 Representational State Transfer,(资源)表现层状态转化
    是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、扩展方便
    具体说,就是 HTTP 协议里面,四个表示操作方式的动 词:
      GET、POST、PUT、DELETE
    
    它们分别对应四种基本操作:
      GET 用来获 取资源
      POST 用来新建资源
      PUT 用来更新资源
      DELETE 用来删除资源

    HiddenHttpMethodFilter:

      浏览器 form 表单只支持 GET 和 POST 请求,不支 持 DELETE、PUT请求
      Spring添加了一个过滤器,可以将这些请求转换 为标准的 http 方法,支持 GET、POST、PUT 和 DELETE 请求
        <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>

    删除:

        <form method="post" id="deleteForm" action="1">
            <input type="text" name="_method" value="DELETE" />
            <button>DELETE提交</button>
        </form>
        @RequestMapping(value="/{id}", method=RequestMethod.DELETE)
        public String delete(@PathVariable(value="id") Integer id) {
            
            //执行删除
            System.out.println("delete");
            
            return "redirect:/user/list";
        }
  • 相关阅读:
    通讯技术
    (1)sqlserver2017安装
    c# api身份验证和授权
    ()centos7 安装python36
    python 包管理
    ()centos7 安装mysql8.0
    [bzoj1095][ZJOI2007]Hide 捉迷藏 点分树,动态点分治
    bzoj 3544 [ONTAK2010]Creative Accounting 贪心
    BZOJ4300 绝世好题 dp
    bzoj 4295 [PA2015]Hazard 贪心,暴力
  • 原文地址:https://www.cnblogs.com/roxy/p/7604016.html
Copyright © 2011-2022 走看看