美文网首页
SpringMVC请求映射处理中的method参数和params

SpringMVC请求映射处理中的method参数和params

作者: 懂我yet | 来源:发表于2020-12-24 17:03 被阅读0次

    method

    设置接收请求的方式,可以设置成数组。

    • method = RequestMethod.POST(单条记录)
    • method = {RequestMethod.DELETE,RequestMethod.GET} (数组,设置多个请求方法)
      但是在spring4.3之后提供了更便捷的请求方式
    • GetMapping
    • PostMapping
    • ......

    params

    用来限制请求中的参数

    // 必须要求请求中携带username参数
    params={"username"}
    // 不能携带username参数
    params={“!username”}
    // 必须要求请求中携带username参数,且username的值为"123"
    params={"username=123"}
    // username参数必须不等于"123"
    params={"username!=123"}
    

    headers

    需要包含对应的请求头,才可以访问该地址

    header={"header-key=XX"}
    

    consumes

    设置映射的文件类型

    consumes={“application/x-www-form-urlencoded”}
    

    produces

    设置响应的文件类型

    produces={"application/json"}
    

    相关文章

      网友评论

          本文标题:SpringMVC请求映射处理中的method参数和params

          本文链接:https://www.haomeiwen.com/subject/pnwmnktx.html