当前位置:网站首页>Rest使用与原理
Rest使用与原理
2022-07-25 09:26:00 【今天你学习了ma】
1.当我们 需要用到delete和put方式发送请求时,会发现请求的默认方式还是get,我们需要配置一个 hiddenHttpMethodFilter ,springboot已经默认配置好了,我们需要手动去开启.

开启方式,也可以说是使用方式


默认使用post方式,只需要在隐藏域 _method后指定是以put或者delete方式就ok
最后一步:在yml配置文件中开启hiddenHttpMethodFilter
spring:
mvc:
hiddenmethod:
filter:
enabled: true若我们需要修改默认的 隐藏域名称 _method
方发: 通过一下方法就变成 了 _Z

package com.zwz.springbootweb.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.HiddenHttpMethodFilter;
@Configuration(proxyBeanMethods = false)
public class WebConfig {
@Bean
public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();
hiddenHttpMethodFilter.setMethodParam("_Z");
return hiddenHttpMethodFilter;
}
}
Rest原理:
表单提交会带上_method=PUT,请求过来被 HiddenHttpMethodFilter拦截,检查请求是否正常,并且是POST
获取到_method的值(兼容以下请求:PUT.DELETE.PATCH)
原生request(post),包装模式requesWrapper重写了getMethod方法,返回的是传入的值。
过滤器链放行的时候用wrapper。以后的方法调用getMethod是调用requesWrapper
若在客户端比如安卓开发不需要用 HiddenHttpMethodFilter,直接用原生servelt掉对应方法
边栏推荐
- Coredata storage to do list
- ROS distributed operation -- launch file starts nodes on multiple machines
- js利用requestAnimationFrame实时检测当前动画的FPS帧率
- 概率论与数理统计 3 Discrete Random Variables and Probability Distributions(离散随机变量与概率分布) (下篇)
- The way of code neatness -- hit the pain point directly
- 字符串切片的用法
- C语言基础
- 工程监测无线中继采集仪和无线网络的优势
- VCs common commands
- Is binary cross entropy really suitable for multi label classification?
猜你喜欢

阿里MQTT物联网平台“云产品流转”实战——两片ESP32通过物联网平台实现远程互操作

无线中继采集仪的常见问题

¥ 1-1 SWUST OJ 941: implementation of consolidation operation of ordered sequence table

【近万字干货】别让你的简历配不上你的才华——手把手教你制作最适合你的简历

OC -- packaging class and processing object
![腾讯云之错误[100007] this env is not enable anonymous login](/img/a2/a209a0d94e3fbf607242c28d87e2dd.png)
腾讯云之错误[100007] this env is not enable anonymous login

Probability theory and mathematical statistics 4 continuous random variables and probability distributions (Part 1)

mysql历史数据补充新数据

Configuring ROS development environment with vscode: Causes and solutions to the problem of ineffective code modification

ROS distributed operation -- launch file starts nodes on multiple machines
随机推荐
Connection and data reading of hand-held vibrating wire vh501tc collector sensor
Record some JS tool functions
Redux使用和剖析
~3 CCF 2022-03-2 travel plan
message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“
FPGA basic advanced
记录一些JS工具函数
无线振弦采集仪的使用常见问题
一.初始MySQL,MySQL安装、配置环境、初始化
车辆属性最近一次入库时间初始化生成sql脚本文件
Subtotal of rospy odometry sinkhole
Advanced introduction to digital IC Design SOC
Swift simple implementation of to-do list
关闭brew执行命令时的自动更新
mysql历史数据补充新数据
Introduction to arm GIC
vscode插件开发
数据库MySQL详解
How Android uses ADB command to view application local database
[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)