SpringMVC-@RequestBody

2022-09-09 14:37:18

一、介绍
@RequestBody用于获取请求体中的数据,其属性required默认为true。

二、项目测试
(1)编写Controller类

@ControllerpublicclassMyController{@RequestMapping(value={"/hello"})publicStringhello(@RequestBodyString body,String username,String password){System.out.println(body);System.out.println(username+ password);return"hello";}}

(2)运行
在这里插入图片描述
在这里插入图片描述

  • 作者:qq_25243147
  • 原文链接:https://blog.csdn.net/qq_25243147/article/details/124201138
    更新时间:2022-09-09 14:37:18