定制相应头
/** * 将返回数据放在响应体中 * * 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); }