• springmvc从stream中获取参数,加idea测试


    背景:直接接收流数据,直接输出流数据

    @RestController
    @Slf4j
    public class HelloController {
    
    
        @PostMapping(value = "/hello",produces = "application/json")
        public void hello(HttpServletRequest request, HttpServletResponse response) throws IOException {
            String encoding = request.getCharacterEncoding();
         // 从流中获取数据 String body
    = StreamUtils.copyToString(request.getInputStream(), Charset.forName(encoding)); log.info("log : {} ",body); String resp="<html><head>i am head</head><body>i am body <body></html>";
        // 将数据写入输出流中 response.getOutputStream().write(resp.getBytes()); }

    idea插件测试接口,类似postman功能

    位置:tools--> http client --> test restful web service

     (愿idea越发强大)

  • 相关阅读:
    顺序容器
    forward_list
    array
    第十一章 关联容器
    C++数组
    C++标准库算法
    第十章 泛型算法
    第九章 顺序容器
    操作系统概述
    文件输入输出
  • 原文地址:https://www.cnblogs.com/windy13/p/12782924.html
Copyright © 2020-2023  润新知