Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 시큐리티
- 오라클
- oracle
- JPA
- mybatis
- jquery
- GitHub
- Eclipse
- Java
- 방법
- 코틀린
- Security
- Git
- 함수
- 알고리즘
- JavaScript
- 스프링
- kotlin
- IntelliJ
- Spring
- 넥사크로
- 자바
- 프로그래머스
- aws
- error
- 쿼리
- db
- Vue
- 에러
- 생성
Archives
- Today
- Total
송민준의 개발노트
[406] path variable email을 사용하는 경우 에러 해결방안 본문
기본적으로 URL 을
http://localhost:8088/hansong/v1/members/test@kakao.com
위처럼 해주면 뒤에 .com을 빼고 변수에 담는다.
이에 대한 해결방안은 뒤에 ':.+' 를 붙여주는 것인데 예를 들어
@GetMapping(value = "/{email:.+}")
public EntityModel<Member> getUser(@PathVariable String email) {
위와 같이 해주면 된다.
이렇게 해도 406에러가 발생한다면 스프링 설정을 하나 추가해줘야한다.
javaconfig 기준으로 WebMvcConfigurer 를 상속받는 곳에서 아래와 같이 설정해준다.
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
}
아래 경로를 참고했으며 외국형님들도 나와 같은 고민을 했던 것 같다.
Error 406 while using an email address as a path variable in Spring Boot
I came across an issue while developing a new endpoint on a Spring boot app. Basically, a REST endpoint with a GET mapping defined in a…
medium.com
'웹 > Spring Framework' 카테고리의 다른 글
ThreadLocal이란 뭘까? (0) | 2020.12.04 |
---|---|
checked, unchecked exception이란? (0) | 2020.11.26 |
[spring] 테스트 중 Unable to initialize 'javax.el.ExpressionFactory' 해결하기 - validator 2.0.0(JSR-380) 적용 (0) | 2020.10.21 |
mybatis procedure 사용법 (0) | 2020.10.19 |
Spring transactional (0) | 2020.07.15 |