https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-ann-responsebody
@ResponseBody와 비슷한데 HttpStatus와 헤더 정보를 같이 보낼 수 있다.
@RequestMapping("/resEntity")
@Controller
public class ResponseBodyController {
@ResponseBody
@GetMapping("/void")
public ResponseEntity<Void> responseVoid() {
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ResponseBody
@GetMapping("/string")
public ResponseEntity<String> responseString() {
return new ResponseEntity<String>("success", HttpStatus.OK);
}
@ResponseBody
@GetMapping("/beans")
public ResponseEntity<Member> responseBeans() {
Member member = new Member();
member.setId("hong");
member.setName("홍길동");
return new ResponseEntity<Member>(member, HttpStatus.OK);
}
}
SpringMVC - @ModelAttribute (메소드 레벨) (0) | 2022.06.01 |
---|---|
Spring MVC @ResponseBody (0) | 2022.05.30 |
Spring MVC @RequestBody (0) | 2022.05.26 |
댓글 영역