📜  java responseentity - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:17.158000             🧑  作者: Mango

代码示例2
@GetMapping("/customHeader")
ResponseEntity customHeader() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Custom-Header", "foo");
        
    return new ResponseEntity<>(
      "Custom header set", headers, HttpStatus.OK);
}
//Simple way
@GetMapping("/hello")
ResponseEntity hello() {
    return ResponseEntity.ok("Hello World!");
}