[개념이해 참고할 블로그.](https://m.blog.naver.com/scw0531/220988401816)
<aside> 💡 @Controller의 역할에 대해 알아보기. @Autowired, @Service, @Repository에 대해 알아보기.
</aside>
<순서> View ⇒Controller ⇒Service ⇒DAO(Repository)⇒DB
ex)전체보기 기능 예시
**View (**index.jsp) href 주소 "list.go" 부여
**Controller (**PerController.java) @Controller, @Autowired (Service 인터페이스 연결) 주소 "list.go"를 @RequestMapping 함. (view 연결) service 객체의 전체보기 메소드를 연결. personList.jsp를 return 함.
Service (PersonServiceImpl.java) @Service, @Autowired (DAO 인터페이스 연결) dao객체의 전체보기 메소드를 연결.
DAO (PersonDAOImpl.java) @Repository, @Autowired (template 연결) SQL문으로 DB연결
New-Dynamic Web Project-03_SpringTest 생성
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>" xmlns="<http://xmlns.jcp.org/xml/ns/javaee>" xsi:schemaLocation="<http://xmlns.jcp.org/xml/ns/javaee> <http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd>" id="WebApp_ID" version="4.0">
<display-name>03_SpringTest</display-name>
<servlet>
<servlet-name>springtest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springtest</servlet-name>
<url-pattern>*.go</url-pattern>
</servlet-mapping>
<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>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?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>"
xmlns:util="<http://www.springframework.org/schema/util>"
xsi:schemaLocation="<http://www.springframework.org/schema/beans> <http://www.springframework.org/schema/beans/spring-beans-4.0.xsd>
<http://www.springframework.org/schema/context> <http://www.springframework.org/schema/context/spring-context-4.0.xsd>
<http://www.springframework.org/schema/util> <http://www.springframework.org/schema/util/spring-util-4.0.xsd>">
<!-- 패키지 등록 -->
<context:component-scan base-package="org.person"/>
<!-- db설정 -->
<bean id="ds" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc/spring</value>
</property>
<property name="resourceRef" value="true"></property>
</bean>
<!-- template설정 -->
<bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="ds"></property>
</bean>
<!-- viewResolver설정 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>