zoukankan      html  css  js  c++  java
  • spring mvc接收form data和query string parameters表单参数

    POST、PUT、DELETE请求不指定Content-Type时,默认使用application/x-www-form-urlencoded

    这时参数提交方式是form data

    POST请求默认会将参数填充的servlet的请求参数中,PUT、DELETE不会。所以会有后两种请求拿不到参数的问题。怎么解决?

    两个思路:

    (1)将PUT、DELETE请求转为POST

    (2)用Filter将参数填充的servlet的请求参数中

    下面是第二种思路:

    旧的spring 版本配置 HttpPutFormContentFilter,只能解决PUT请求参数的填充。可以自定义补充实现DELETE的请求的逻辑,参考FormContentFilter(照抄也没问题,亲测)

    新的spring 版本配置 FormContentFilter,可以解决PUT、DELETE请求参数的填充。

    配置web.xml

    <filter>
    <filter-name>MyFormContentFilter</filter-name>
    <filter-class>com.test.filters.MyFormContentFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>MyFormContentFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    GET请求参数提交方式是query string parameters

    @RequestParam就可以解析

  • 相关阅读:
    有序数组(类模板)
    BUUCTF-Web Comment
    BUUCTF-web NiZhuanSiWei
    2020数字中国创新大赛虎符网络安全赛道-pwn count
    BUUCTF-Web Easy Calc
    xctf-web fakebook
    xctf-web supersqli
    xctf-pwn pwn200
    xctf-pwn level3
    利用updatexml()报错注入mysql
  • 原文地址:https://www.cnblogs.com/ouym/p/13445405.html
Copyright © 2011-2022 走看看