Spring

원종서·2021년 9월 30일
0

환경 준비하기

https://tomcat.apache.org/download-90.cgi

https://spring.io/tools

메이븐을 이용한 기본 웹 프로젝트 생성하기

spring tool 상단 Help > Install New Software... > work with 에 http://download.eclipse.org/releases/2020-12 입력 후 엔터 > 맨 마지막에 web,xml,java ee and OSGi Enterprise Develoment 설치

preference -> JAVA EE

maven project 생성하면 web.xml 없다고 에러뜸

src/main/webapp 에다가

/Users/{USERNAME}/Desktop/apache-tomcat-9.0.53/webapps/Root 의 WEB-INF 폴더를 붙여넣기함

// in pom.xml

<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-api -->
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-api</artifactId>
    <version>9.0.53</version>
</dependency>

Dispatcher Servlet 라이브러리 설정하기

https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.2.9.RELEASE
spring-web-mvc

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.2.9.RELEASE</version>
</dependency>

dispatcher-servlet.xml 파일

extends httpServlet 를 하지 않는다.

스프링에서 front contoller 역활을 하기 때문에 (미리 작성된 servlet 코드를 사용하는 것)

기존 servlet에서 url 을 작성했는데

지금은 스프링이 servlet 코드를 관리하니

url 을 작성하기 위해선 web.xml 을 통해 url 을 적어주어야한다.

0개의 댓글