zoukankan      html  css  js  c++  java
  • 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越发强大)

  • 相关阅读:
    Hibernate优缺点
    Struts优缺点
    Problem M
    Problem K
    Problem K
    Problem Q
    Problem Q
    Problem F
    Problem F
    哈夫曼树
  • 原文地址:https://www.cnblogs.com/windy13/p/12782924.html
Copyright © 2011-2022 走看看