Spring Framework(31)
-
HTTP Message Converter
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..
2024.09.02 -
SpringMVC ( Http 응답 처리 )
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를 사용하면 뷰템..
2024.09.02 -
Spring MVC (Http 요청 처리)
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..
2024.09.01 -
Log 설정 및 Logging 사용
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..
2024.09.01 -
Spring MVC ( @RequestMapping )
RequestMapping #1 @RequestMappingHandler와 adapter 둘다 우선적으로 사용되는 부분이 RequestMapping 이다RequestMappingHandlerMappingRequestMappingHandlerAdapter @RequestMapping 사용@Controller//@RequestMapping("/main") 을 하면 해당 메서드에 붙은 /main 부분을 생략할 수 있다public class SpringExampleControllerV1{ @RequestMapping("/main/new-form") public ModelAndView process(){ return new ModelAndView("new-form"); } ..
2024.09.01 -
SPRING MVC 구조 #3 (Dispatcher Servlet, View)
Disptacher #3- View Resolver- View Dispatcher Servlet ( + View)Handler Mapping 과정과 Handler Adapter 과정이 이후에 Controller를 통해 받은 ModelAndView형태의 결과물을 렌더링을 진행하게 된다해당 부분에서 render()함수가 호출되게 된다 Render()doDispatch() 메서드에서 processDispatchResult() 메서드의 호출로 렌더링이 시작되게 된다.this.processDispatchResult(processedRequest, response, mappedHandler, mv, (Exception)dispatchException);private void processDispatchResult..
2024.09.01