定制相應頭
/** * 將返回數據放在響應體中 * * 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); }