괴발개발

[강의 정리]D66 - (web.wml /pom.xml/ root-context /servlet-context) 본문

BACK END/SPRING

[강의 정리]D66 - (web.wml /pom.xml/ root-context /servlet-context)

dinoelll 2023. 4. 6. 23:18

1.  web . xml => 제일 먼저 읽는거

1. 필터 가능 -> 캐릭터셋인코딩

2. servlet, root 읽는 위치 지정 가능

 

2. pom.xml

1. 자바 버전 변경

-1.8 ,4,3,14 / ,1.8 ,1.8 3.7.0

2. 라이브러리 추가

 

3. root-context  => 서버가 켜지면 읽는 파일

1. multipart 관련 설정

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="defaultEncoding" value="UTF-8"/>
		<property name="maxInMemorySize" value="10000000"/>
		<property name="maxUploadSize" value="10000000"/>
	</bean>

 

 

4. servlet-context  => 요청들어오면 읽는 파일

1. resources 요청 위치 지정 가능

2. @ 읽는 위치 지정 가능

3. datasource관련

4. mybatis 연결 관련 + mybatis area 지정

<annotation-driven />

	<!-- resources 라는 요청이 오면... resources 폴더로 연결 해라-->
	<resources mapping="/resources/**" location="/resources/" />

	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
	</beans:bean>
	
	<context:component-scan base-package="kr.co.gudi" />
	
	<!-- datasource -->
	<beans:bean name="datasource" class="org.apache.commons.dbcp.BasicDataSource">
		<beans:property name="driverClassName" value="org.mariadb.jdbc.Driver"/>
		<beans:property name="url" value="jdbc:mariadb://localhost:3306/mydb"/>
		<beans:property name="username" value="web_user"/>
		<beans:property name="password" value="pass"/>
	</beans:bean>
	
	<!-- mybatis -->
	<beans:bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 연결할 DB 정보 -->
		<beans:property name="dataSource" ref="datasource"/>
		<!-- 쿼리문이 있을 장소 -->
		<beans:property name="mapperLocations">
			<beans:list>
				<beans:value>classpath:kr/co/gudi/dao/*.xml</beans:value>
			</beans:list>
		</beans:property>
	</beans:bean>
	
	<!-- mybatis area -->
	<mybatis-spring:scan base-package="kr.co.gudi.dao"/>

 

 

 

Comments