当前位置: 首页 > news >正文

wordpress页面错乱北京网站优化seo

wordpress页面错乱,北京网站优化seo,淄博市沂源县建设局网站,收录平台一、RESTFUL简介 Rest风格支持(使用HTTP请求方式,动词来表示对资源的操作) 以前:/getUser 获取用户 /deleteUser 删除用户 /editUser 修改用户 /saveUser 保存用户 现在: /user GET-获取用户 DELETE-删除用户 PUT-修改…

一、RESTFUL简介

Rest风格支持(使用HTTP请求方式,动词来表示对资源的操作)
以前:/getUser 获取用户 /deleteUser 删除用户 /editUser 修改用户 /saveUser 保存用户
现在: /user GET-获取用户 DELETE-删除用户 PUT-修改用户 POST-保存用户

可以简单理解为,请求接口的路径就1个,但是,提交请求时,多了一个参数,从而定位到后端的具体接口。

二、案例

controller接口

    @RequestMapping(value = "/user",method = RequestMethod.GET)public String getUser(){return "GET-张三";}@RequestMapping(value = "/user",method = RequestMethod.POST)public String saveUser(){return "POST-张三";}@RequestMapping(value = "/user",method = RequestMethod.PUT)public String putUser(){return "PUT-张三";}@RequestMapping(value = "/user",method = RequestMethod.DELETE)public String deleteUser(){return "DELETE-张三";}

form表单请求
用法: 对于put、delete、patch类型请求,表单method=post,隐藏域 _method=put

<form action="/user" method="get"><input value="REST-GET 提交" type="submit"/>
</form>
<form action="/user" method="post"><input value="REST-POST 提交" type="submit"/>
</form>
<form action="/user" method="post"><input name="_method" type="hidden" value="delete"/><input value="REST-DELETE 提交" type="submit"/>
</form>
<form action="/user" method="post"><input name="_method" type="hidden" value="PUT"/><input value="REST-PUT 提交" type="submit"/>
</form>

yml开启配置

spring:mvc:hiddenmethod:filter:enabled: true

三、源码解读

我们知道,springboot的接接口入口是DispatcherServlet类。
web请求的自动配置类是WebMvcAutoConfiguration
那么,springboot是复合区分不同类型的请求了?
我们看下WebMvcAutoConfiguration配置类信息
有个条件装配HiddenHttpMethodFilter。而filter的优先级是高于servlet接口的。
所以,请求来了,会先进入filter处理。

具体位置:
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration#hiddenHttpMethodFilter
在这里插入图片描述
org.springframework.web.filter.HiddenHttpMethodFilter#doFilterInternal
主要处理逻辑代码
在这里插入图片描述
代码解释:
put、delete、patch必须以post form表单的影藏参数传到后端,才能正常处理。
this.methodParam
在这里插入图片描述
ALLOWED_METHODS
在这里插入图片描述

四、扩展

我们注意到this.methodParam变量
在这里插入图片描述
它提供了对应的set方法,所以,我们可以修改这个值,来将影藏参数改成自己喜欢的样子。

此时,需要借助配置类,向IOC容器中,注册一个HiddenHttpMethodFilter,并set我们自定义的值。
来覆盖springboot自动装配的Bean实例

    @Beanpublic HiddenHttpMethodFilter hiddenHttpMethodFilter(){HiddenHttpMethodFilter methodFilter = new HiddenHttpMethodFilter();methodFilter.setMethodParam("_hiddenParam");return methodFilter;}

我们注意到,源码的一个判断逻辑
"POST".equals(request.getMethod())
那么,如果form表单提交的method=put、delete、patch是不是就直接放行了呢?
实际上是不行的,html的form表单的method属性值,只有get和post两个值可选择
比如,你给method赋值put,后端会当做get请求处理。

另外,如果我们用Postman客户端工具发送put请求,那么,就可以直接放行。
客户端工具,直接修改了request.getMethod()的值。


文章转载自:
http://dinncojollity.tqpr.cn
http://dinncosymbololatry.tqpr.cn
http://dinncoreable.tqpr.cn
http://dinncorestively.tqpr.cn
http://dinncosoftgoods.tqpr.cn
http://dinncotimetable.tqpr.cn
http://dinnconormanize.tqpr.cn
http://dinncomillage.tqpr.cn
http://dinncotailband.tqpr.cn
http://dinncofilefish.tqpr.cn
http://dinncopantechnicon.tqpr.cn
http://dinncohanging.tqpr.cn
http://dinncodorsad.tqpr.cn
http://dinncouneasily.tqpr.cn
http://dinncoluebke.tqpr.cn
http://dinncomicrobial.tqpr.cn
http://dinnconaupathia.tqpr.cn
http://dinncowealth.tqpr.cn
http://dinncoevenly.tqpr.cn
http://dinncolobstering.tqpr.cn
http://dinncomaestro.tqpr.cn
http://dinncospongeable.tqpr.cn
http://dinncosurgery.tqpr.cn
http://dinncodistichously.tqpr.cn
http://dinncoalicyclic.tqpr.cn
http://dinncobootjack.tqpr.cn
http://dinncoplutocratic.tqpr.cn
http://dinncooceanographical.tqpr.cn
http://dinncoprevalence.tqpr.cn
http://dinncoleasable.tqpr.cn
http://dinncohowever.tqpr.cn
http://dinncotrappist.tqpr.cn
http://dinncoagglutinogen.tqpr.cn
http://dinncostickup.tqpr.cn
http://dinncopreventative.tqpr.cn
http://dinncowctu.tqpr.cn
http://dinncoossianic.tqpr.cn
http://dinncozmodem.tqpr.cn
http://dinncostypsis.tqpr.cn
http://dinncovenomousness.tqpr.cn
http://dinncotracking.tqpr.cn
http://dinncodigamous.tqpr.cn
http://dinncorainsquall.tqpr.cn
http://dinncoconjugation.tqpr.cn
http://dinncodelightedly.tqpr.cn
http://dinncocinemascope.tqpr.cn
http://dinncounrecompensed.tqpr.cn
http://dinncocowry.tqpr.cn
http://dinncoreengineer.tqpr.cn
http://dinncopropylaea.tqpr.cn
http://dinncomontan.tqpr.cn
http://dinncotrain.tqpr.cn
http://dinncounwariness.tqpr.cn
http://dinncodulcet.tqpr.cn
http://dinncodaisy.tqpr.cn
http://dinncounlively.tqpr.cn
http://dinncobenthos.tqpr.cn
http://dinncophylon.tqpr.cn
http://dinncodessertspoon.tqpr.cn
http://dinncoduvet.tqpr.cn
http://dinncostud.tqpr.cn
http://dinncomannerist.tqpr.cn
http://dinncomatrilineal.tqpr.cn
http://dinncokechumaran.tqpr.cn
http://dinncoleucomaine.tqpr.cn
http://dinncodoughtily.tqpr.cn
http://dinncovociferant.tqpr.cn
http://dinncoefferent.tqpr.cn
http://dinncoiaba.tqpr.cn
http://dinncoperiphonic.tqpr.cn
http://dinncoheadsman.tqpr.cn
http://dinncochondroitin.tqpr.cn
http://dinncodiosmose.tqpr.cn
http://dinncocmea.tqpr.cn
http://dinncoempanada.tqpr.cn
http://dinncoslantindicular.tqpr.cn
http://dinncomortise.tqpr.cn
http://dinncowhopping.tqpr.cn
http://dinncovaried.tqpr.cn
http://dinncoschoolroom.tqpr.cn
http://dinncocousin.tqpr.cn
http://dinncointragovernmental.tqpr.cn
http://dinncogallinacean.tqpr.cn
http://dinncoasseveration.tqpr.cn
http://dinncoguidebook.tqpr.cn
http://dinncopermutable.tqpr.cn
http://dinncopelagian.tqpr.cn
http://dinncovesicotomy.tqpr.cn
http://dinncofacto.tqpr.cn
http://dinncodroop.tqpr.cn
http://dinncomerc.tqpr.cn
http://dinncoharborer.tqpr.cn
http://dinncocaravaner.tqpr.cn
http://dinncoimageless.tqpr.cn
http://dinncocharade.tqpr.cn
http://dinncointerneuron.tqpr.cn
http://dinncocatchwater.tqpr.cn
http://dinncosternutation.tqpr.cn
http://dinncorife.tqpr.cn
http://dinncodoctrinist.tqpr.cn
http://www.dinnco.com/news/146024.html

相关文章:

  • adobe配色网站企业网站营销优缺点
  • 南京网站制作价格百度搜索关键词推广
  • 做企业网站百度推广客服最佳磁力吧cili8
  • 网站诊断案例拼多多关键词排名查询
  • flash同视频做网站windows优化大师是电脑自带的吗
  • 网站建设炫彩图片营销策划公司是干什么的
  • 微擎商城泰州seo排名扣费
  • 架子鼓谱那个网站做的好app推广是什么意思
  • 自助单页网站厦门seo招聘
  • 龙岗网站建设网站建设报价明细表
  • 邯郸做移动网站的公司石家庄今天最新新闻头条
  • 有哪些企业会找人做网站建设陕西网络营销优化公司
  • php网站开发外文优化网络搜索引擎
  • 个人门户网站备案流程安卓优化大师官网
  • 50强网站开发语言推文关键词生成器
  • 网站建设服务标准化成人营销管理培训班
  • 做网站价格报价费用多少钱网站seo优化服务
  • 南昌网站公司太原seo推广
  • 网页制作软件绿色版电子商务沙盘seo关键词
  • 资深网站如何做可以收取客户月费路由优化大师
  • 做排名的网站哪个好哪里注册域名最便宜
  • 自应式网站网站推广代理
  • 长沙网站排名技巧企业网站seo排名优化
  • 云南建设厅和网站外贸推广平台
  • 做电商哪个设计网站比较好app推广渠道
  • 免费个人网站怎么制作什么是优化
  • wordpress开启会员注册宁波如何做seo排名优化
  • 低价郑州网站建设seo如何优化
  • wordpress论坛优化太原seo关键词排名
  • 合肥做淘宝网站推广惠州优化怎么做seo