- handleRequest 메서드 안에서, ModelAndView 객체를 만들어 리턴한다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- schemaLocation 에서 복사 붙여 넣기 할때! 한칸 띄고 엔터후 붙여 넣어야 한다!
** 중요 ** 한칸 띄고!!
-->
<!-- 이렇게 하면 db.properties 안의 것들이 로드가 된다. -->
<context:property-placeholder
location="classpath:mybatis/props/db.properties"/>
<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.user}"/>
<property name="password" value="${jdbc.pwd}"/>
<property name="defaultAutoCommit" value="false"/><!--오토커밋 기본 값은 true-->
</bean>
<bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="ds"/>
<property name="mapperLocations" value="classpath:mybatis/mapper/*.xml"/>
</bean>
<bean id="ss" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="factory"/>
</bean>
<!-- autowire="byName" 속성은 bbsDao 클래스의 멤버변수 이름과
위에서 생성한 bean 객체의 id가 같으면 자동으로 값을 넣어준다 -->
<bean id="bbsDao" class="mybatis.dao.BoardDAO" autowire="byName"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- 아래 구문을 추가하여 어노테이션을 사용 할 수 있다. -->
<context:annotation-config/>
<!-- 각 컨트롤러 선언 -->
<bean name="/list.inc" class="spring.control.ListControl">
<property name="bbsDao" ref="bbsDao"/>
</bean>
<!-- View Resolver 선언 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>