inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

다국어 처리를 위한 Internationalization 구현 방법

수업 그대로 따라했는데 404오류가 발생합니다.

315

k1mdev

작성한 질문수 3

0

안녕하세요 다국어 처리 수업 중에 수업 그대로 작성했는데 이러한 오류가 발생하게 됩니다.
뭐 때문에 이러한 오류가 나는지 모르겠습니다..

rest-api spring-boot

답변 2

0

Dowon Lee

안녕하세요, 이도원입니다.

말씀하신, 다국어 테스트를 위한 hello-world-internationalized 를 요청 시 404 오류가 발생하는 것은 말 그대로 해당 Resource를 찾을 수 없다는 오류이기 때문에, hello-world-internationalized가 구현 된 HelloWorldController 클래스에 오류가 없는지, RequestMapping 또는 GetMappinng 등의 설정이 잘 되었는지 확인해 보시면 좋을 것 같습니다. HelloWorldContoller의 다른 메소드드른 정상 사용이 되면서, hello-world-internationalized 메소드에만 문제가 있는 것인지도 확인해 보시면 좋을 것 같습니다.

@RestController
public class HelloWorldController {
    private MessageSource messageSource;

    public HelloWorldController(MessageSource messageSource) {
        this.messageSource = messageSource;
    }

    @GetMapping(path = "/hello-world")
    public String helloWorld() {
        return "Hello World";
    }

    @GetMapping(path = "/hello-world-bean")
    public HelloWorldBean helloWorldBean() {
        return new HelloWorldBean("Hello Wolrd");
    }

    // hello-world-bean/path-variable/kennet
    @GetMapping(path = "/hello-world-bean/path-variable/{name}")
    public HelloWorldBean helloWorldBean(@PathVariable String name) {
        return new HelloWorldBean(String.format("Hello World, %s ", name));
    }

    @GetMapping(path = "/hello-world-internationalized")
    public String helloWorldInternationalized(
            @RequestHeader(name="Accept-Language", required=false)  Locale locale) {
        return messageSource.getMessage("greeting.message", null, locale);
    }
}

위 내용 확인 시에도 오류 해결이 되지 않으시면, 아래 공유된 소스로 한번 실행해 보시기 바랍니다.

https://github.com/joneconsulting/new-my-restful-service

감사합니다.

0

인프런 AI 인턴

안녕하세요, 인프런 AI 인턴입니다.

k1m1님, 요청하신 API 경로가 서버에서 찾을 수 없어 발생하는 404 오류로 보입니다.

이 경우, 몇 가지 확인해볼 사항이 있습니다:
1. 서버 측에서 해당 경로(/hello-world-internationalized)로 요청을 처리할 수 있는 @RestController의 @RequestMapping 설정이 제대로 되어있는지 확인하세요.
2. application.propertiesapplication.yml 파일에 다국어 설정이 올바르게 적용되었는지 검토해보세요.
3. 프로젝트 내에 URI와 일치하는 스프링 컨트롤러 메소드가 존재하는지 확인하세요.

이 오류는 주로 서버 측에서 요청받은 리소스의 경로를 찾지 못했을 때 발생합니다. 스프링 부트의 @RestController 주석 및 관련 매핑 설정을 다시 검토하시길 바랍니다. 만약 다국어 처리 기능이 포함된 API 경로 설정에 문제가 없다면, 서버가 올바르게 구동되고 있는지 확인해주세요.

추가 문제 해결에 필요하신 정보가 있다면, 아래의 문서도 참조하실 수 있습니다:
- Spring Boot에서 JSON REST 서비스 작성 방법: Spring Boot Reference Documentation

감사합니다.

JPA

0

57

1

jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.

0

68

1

웹 브라우저 400 bad request

0

70

1

@Size는 되는데 @Past는 안 됩니다.

0

61

1

pdf 자료는 없나요?

0

73

2

locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제

0

87

2

Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고

0

118

1

강의에서나온 화면 피피티

0

158

1

HelloWorldBean 관련 에러

0

183

2

Swagger API 3.x 오류..

0

219

1

java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?

1

282

1

현재 GIT에 올리신 소스를 실행해봤습니다.

0

189

2

고양이 소리가 귀엽네요 !!

0

137

2

git에서 소스받고 실습중인데

0

117

1

post가 안되요

0

102

1

한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?

0

167

2

리턴타입으로서 EntityModel<User> 와 ResponseEntity질문

0

103

1

예외처리쪽 관련 질문있습니다.

0

159

2

엔티티가 바로 응답으로 나가도 되나요??

0

221

2

안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null

0

135

2

사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.

0

140

2

ApplictionContext 질문

0

191

2

롬북이 안먹히는것같아요

0

156

1

인텔리제이에서스프링부트 파일 실행하면

0

239

1