Bean Validation Bean Validation 사전 준비Bean Validation 사용 전 gradle 추가 implementation 'org.springframework.boot:spring-boot-starter-validation' 검증 Annotation@NotBlank빈값 + 공백만 있는 경우를 허용하지 않는다@NotNullnull을 허용하지 않는다@Range(min=숫자1, max= 숫자2)숫자1 ~ 숫자2 범위까지 가능@Max(숫자)지정 숫자까지 최대 지정 가능 Bean Validation 검증 순서@ModelAttribute로 객체로 변환 ( -> 실패시, typeMistMatch로 FieldError 추가 == Bean Validation 적용 x)객체로 변환될시, Val..
Validation Validation 방법HashMap 과 StringUtils를 이용한 JAVA 직접 구현 (+ RedirectAttrubutes)BindigResult를 이용Validator 분리 Validatie 구현HashMap 과 StringUtils 및 Redirect 를 이용한 방법HashMap : error 담을 바구니StringUtils : Null 체크redirectAttributes : 리다이렉트시 정보 전달@PostMapping("url")public String func(@ModelAttribute("item") Item item, RedirectAttributes redirectAttributes, Model model){ Maperrors = new Hash..
1. 메시지2. 국제화 Bean 등록 (message) 직접 등록@Bean public MessageSource messageSource(){ ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasenames("messages", "errors"); messageSource.setDefaultEncoding("utf-8"); return messageSource; }자동 등록messages 라고 자동 등록 되어있음spring boot 등록spring.messages.basename=messages (기본 값)// 값의 messages를 변경하면 파일이름을 다르게 설정할 수 있..
Thymeleaf 선언html 문서에 해당 문구를 적어야, thymeleaf 템플릿을 사용해야하는 것을 인지할 수 있다 Text 출력Model Attribute 값 출력${data}html 이스케이프 회피th:utext Object 출력th:text="${user.username}"th:text="${user['username']}"th:text="${user.getUsername()}" List 출력th:text="${users[0].username}"th:text="${users[0]['username']}"th:text="${users[0].getUsername()}" Map 출력th:text="${userMap['userA'].username}"th:text="${userMap['userA']['..
HTTP Message Converter 란?HTTP message Converter는 메시지 형식에 따라 맞추어 변환시켜주는 작업주로 HTTP API 및 text 를 message Body에 반환시에 사용됨Controller에 데이터가 들어오고 응답으로 나갈때 message Converter가 작동함 SpringMVC의 message Converter 적용 시기HTTP 요청@RequestBodyHttpEntity(RequestEntity)HTTP 응답@ReponseBodyHttpEntity(ResponseEntity) Spring boot의 기본 메시지 컨버터0 = ByteArrayHttpMessageConverter1 = StringHttpMessageConverter2 = MappingJackson..
HTTP 응답 방법정적 리소스 /static , /public, /resources, /META-INF/resourcessrc/main/resources : 리소스를 보관, 클래스패스의 시작 경로View Templatesrc/main/resources/templates : 기본 뷰 템플릿 경로HTTP API , 메시지 바디에 직접 입력 View Template 응답src/main/resources/templates/response/hello.html empty 방법ModelAndView를 반환Model을 이용해서 데이터 전달 + URL 문자열로 전달요청 URL 과 응답 URL 이름이 동일하면 생략 (권장 x -> 명시성이 떨어짐)@ResponseBody, HttpEntity를 사용하면 뷰템..
HTTP 요청 파라미터 방법GET - 쿼리 파라미터URL 쿼리 파라미터에 데이터를 포함해서 전달POST - HTML FormContent-Type : application/x-www-form-urlencoded메시지 body 부분에 쿼리 파라미터 형식으로 전달 ( ex) username=hello&age=20 )HTTP message bodyHTTP API 사용 (JSON, XML, TEXT ) HTTP 요청 파라미터request.getParameter("[변수]")String username = request.getParameter("username"); @RequestParam("[변수]")public String Example( @RequestParam("username") String member..
LoggingSLF4J수많은 로그 라이브러리들을 통합해서 인터페이스로 만든 것을 "SLF4J" 라고 함Spring에서는 Logback, Log4J, Log4J2 등 많은 로그들이 있지만, 스프링 부트는 Logback을 대부분 사용함 Logging 사용Logging 선언private Logger log = LoggerFactory.getLogger(getClass());private static final Logger log = LoggerFactory.getLogger(xxx.class)Logging 호출log.trace("[내용]");log.debug("[내용]");log.info("[내용]");log.warn("[내용]");log.error("[내용]");Logging LevelTrace > Debu..
- Total
- Today
- Yesterday
- 예외처리
- 검증
- BFS
- 오블완
- Java
- bean
- 백준
- 정렬
- 우선순위 큐
- 기술면접
- 포트폴리오
- JSON
- db
- DFS
- 이진탐색
- 티스토리챌린지
- Spring
- JDBC
- 알고리즘
- Thymeleaf
- HTML5
- 버블정렬
- stack
- 코딩테스트
- SQL
- 게시판
- 깊이우선탐색
- 게시판 프로젝트
- 클래스
- 타입변환
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |