@ResponseEntity返回值(怪异)

定制相应头

/**
     * 将返回数据放在响应体中
     * 
     * ResponseEntity<String>:响应体中内容的类型
     * @return
     */
    //@ResponseBody
    @RequestMapping("/haha")
    public ResponseEntity<String> hahah(){
        
        MultiValueMap<String, String> headers = new HttpHeaders();
        String body = "<h1>success</h1>";
        headers.add("Set-Cookie", "username=hahahaha");
        
        return new ResponseEntity<String>(body , headers, HttpStatus.OK);
    }

 

posted @ 2019-11-21 17:25  月半大熊猫  阅读(1822)  评论(0编辑  收藏  举报