JAVA/SPRING

[SPRING] SPRING 게시판 (1) - 프로젝트 생성

KMSEOP 2020. 3. 10. 20:25
728x90

프로젝트 생성

Spring Legacy Project -> Spring MVC Project

패키지명 지정

 

톰캣 설정

설치된 톰캣 버전을 따라서 설정

 

Character Encoding 설정

<!-- webapp/WEB-INF/web.xml -->

	<!--  Character Set Filter -->
	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>
			org.springframework.web.filter.CharacterEncodingFilter
		</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

 

스프링 환경 설정

servlet-context.xml를 [src/main/resources/]에 root-context.xml는 [src/main/resources/]에 spring이라는 폴더를 만들어 관리

<!-- webapp/WEB-INF/web.xml -->

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring/*-context.xml</param-value> <!-- 변경 -->
	</context-param>
	
	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- 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>classpath:servlet-context.xml</param-value> <!-- 변경 -->
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

 

 

728x90