본문 바로가기

hellokiseok

검색하기
hellokiseok
프로필사진 hellokiseok

  • 분류 전체보기 (5)
    • Spring (1)
    • Hibernate (1)
    • Docker (3)
    • Intellij IDEA (0)
Guestbook
Notice
Recent Posts
Recent Comments
Link
  • KSUG
«   2025/07   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
  • docker
  • Spring MVC
  • namedqueries
  • Example
  • content-type
  • Spring
  • jsonview
  • MySQL
  • hibernate
  • HttpHeader
  • nextjs
  • Redis
  • RESTful
  • mock
  • docker-compose
  • test
  • junit
  • Intellij
  • ExceptionHandler
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록ExceptionHandler (1)

hellokiseok

@ExceptionHandler 사용법 + Content-Type 별 처리

RESTful 서비스에서, 하나의 URI 에서 Content-Type 에 따라 다른 Exception 처리를 하고싶을때 어떻게 해야할까? Content-Type 이 application/json 일때 exception 정보를 json 데이터로 받아 볼수 없을까? 방법은 간단하다. 아래 소스를 보면 HttpRequestHeader 정보에서 Content-Type 정보를 읽어올수 있다. 그래서 Response Content-Type 에 따라 다른 ModelAndView 를 생성해주면 된다. json 데이터로 넘겨주고 싶을땐 "jsonView" 를 생성하고 html 로 넘겨주고 싶을때는 jsp view 를 생성해주면 된다. 이렇게 하면 동일한 URI 에서 Content-Type 별로 다른 결과를 받아 볼수 있..

Spring 2013. 8. 14. 14:12
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바