Codit Develop
Codit Develop
Codit Develop
전체 방문자
오늘
어제
  • 분류 전체보기 (146)
    • IT (1)
      • 스마트폰 (1)
    • Game (59)
      • DNF (0)
      • StarCraft2 (11)
      • LostArk (45)
      • Minecraft (3)
      • Elyon (0)
    • Develop (43)
      • Web (15)
      • PHP (2)
      • Laravel (0)
      • C# (11)
      • NodeJS (1)
      • Java (2)
      • Python (1)
      • Cordova (3)
      • Android (0)
      • WPF (1)
      • PowerShell (5)
      • Other (2)
      • Javascript (0)
    • OS (17)
      • Windows (6)
      • Linux (11)
    • Product (17)
      • Docker (10)
      • GitLab (3)
      • NuGet (2)
      • Git (1)
      • Nginx (1)
    • DB (7)
      • All-DB (2)
      • MariaDB (2)
      • MySQL (2)
      • Oracle (0)
      • MSSQL (1)
      • Cubrid (0)
    • PC (2)
      • 견적함 (2)
      • 정보 (0)

블로그 메뉴

    공지사항

    인기 글

    태그

    • 로스트아크
    • 디펜스
    • jQuery
    • 몬스터
    • MySQL
    • 모험의
    • JavaScript
    • 구릉지
    • 뷰포인트
    • 개복디
    • 오즈혼
    • docker
    • 서
    • css
    • db
    • 스타2
    • html
    • 유디아
    • 히든
    • Linux
    • 개인복권디펜스
    • 씨앗
    • web
    • 숨겨진
    • 모험의 서
    • 모험의서
    • 아르테미스
    • 모코코
    • 조합
    • c#

    최근 댓글

    최근 글

    티스토리

    hELLO · Designed By 정상우.
    Codit Develop

    Codit Develop

    [Java] Spring Boot Rest API 응답 코드 변경
    Develop/Java

    [Java] Spring Boot Rest API 응답 코드 변경

    2022. 2. 10. 10:07
    반응형

    ResponseEntity 사용

    사용처

    • Spring Boot에서 API Return 시 응답 코드 변경에 사용

    Package

    org.springframework.http.ResponseEntity

    사용법

    return new ResponseEntity(SEND_DATA , HTTP_STATUS)
    • SEND_DATA : JSON 형식으로 보낼 파일
    • HTTP_STATUS : 응답 코드
      • org.springframework.http.HttpStatus

    Example

    @RequestMapping(method = RequestMethod.GET, path = "login")
    public ResponseEntity Login(String id, String password){
        try{
            LoginEntity userinfo = LoginService.GetUserData(id,password);
    
            return new ResponseEntity(userinfo,HttpStatus.OK); // 200 Code
        }
        catch (Exception ex){
            return new ResponseEntity( ex , HttpStatus.BAD_REQUEST); //400 Code (ERROR)
        }
    
    }
    반응형
    저작자표시 비영리 변경금지 (새창열림)

    'Develop > Java' 카테고리의 다른 글

    [Eclipse] The selection cannot be launched and there are no recent launches  (0) 2020.05.19
      'Develop/Java' 카테고리의 다른 글
      • [Eclipse] The selection cannot be launched and there are no recent launches
      Codit Develop
      Codit Develop
      내가 보려고 만든 개발 블로그

      티스토리툴바