사용자 도구

사이트 도구


springframework:springboot:mvc

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판 양쪽 다음 판
springframework:springboot:mvc [2020/07/09 14:47]
kwon37xi [설정 커스터마이즈]
springframework:springboot:mvc [2020/07/09 15:05]
kwon37xi [Formatter]
줄 14: 줄 14:
   * [[https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.html|WebMvcConfigurer]] ''addFormatters''로 등록.   * [[https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.html|WebMvcConfigurer]] ''addFormatters''로 등록.
   * Formatter와 Jackson Serializers/Deserializers 에 대해서 테스트를 만들어 보증하는 것이 좋다. [[https://gist.github.com/kwon37xi/aa359e364b7e81f79085fb04cc710037|FormatterSerializerTestControllerTest.groovy]]   * Formatter와 Jackson Serializers/Deserializers 에 대해서 테스트를 만들어 보증하는 것이 좋다. [[https://gist.github.com/kwon37xi/aa359e364b7e81f79085fb04cc710037|FormatterSerializerTestControllerTest.groovy]]
 +
 +==== Java 8 java.time.* Formatter 일괄 등록 ====
 +  * from https://stackoverflow.com/a/47934151/1051402
 +  * 아래 설정은 Java 8 ''java.time.*'' 의 Formatter 를 일괄등록해준다.
 +
 +<code java>
 +@Configuration
 +public class MyApiWebMvcConfig  implements WebMvcConfigurer {
 +
 +    @Override
 +    public void addFormatters(FormatterRegistry registry) {
 +        DateTimeFormatterRegistrar dateTimeFormatterRegistrar = new DateTimeFormatterRegistrar();
 +        dateTimeFormatterRegistrar.setUseIsoFormat(true); // ISO 포맷 사용시, 그게 아니면 각자 명시적 설정
 +        dateTimeFormatterRegistrar.registerFormatters(registry);
 +    }
 +}
 +</code>
 +
 ===== Converter ===== ===== Converter =====
  
  
springframework/springboot/mvc.txt · 마지막으로 수정됨: 2020/07/17 10:21 저자 kwon37xi