




웹 환경

mvc2의 구조

Spring MVC
- Dispatcher servlet : 프론트컨트롤러 처럼 제어를 담당


초기 버전
Dispatcher servlet가 핸들러맵퍼한테 어디로 보낼지 물어봄 -> 인스턴스를 알려줌 -> 디스패처가 해당 컨트롤러에 요청





my batis : 동적쿼리를 만들기 쉽해 해주는 프레임워크
service 레이어 :

기능 하나마다 컨트롤러 만드는 것은 예전 방식


web.xml 톰캣이 가동되면 제일 먼저 실행

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
1. 다른 XML(root-context.xml)을 가동해라 > 비어있음
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2. DispatcherServlet 생성, (servlet-context.xml) 가동



핸들러 맵퍼의 역할 수행

package kh.spring.controller;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
//@component
//@Controller
//@Service
//@Repository
// http://IPaddress:8080/
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
return "home";
}
}


'디지털 컨버전스 > Spring' 카테고리의 다른 글
| [Spring Framework] (0) | 2020.05.29 |
|---|---|
| [Spring Framework] 서버 연결 (0) | 2020.05.27 |
| [Spring Framework] Annotation (0) | 2020.05.27 |
| [Spring Framework] 설정, DL / DI , IOC (0) | 2020.05.27 |
| [Spring Framework] 설치 (0) | 2020.05.26 |