Spring MVC with XML

stan·2023년 8월 9일
0

Spring

목록 보기
7/22
  • xml이면 HM, VR
    xml일때란 : HM,C,VR들을 DS.xml에서 직접 설정 해서 쓸때
    new라고 적혀야 개발자가 new한거임
  • 어노테이션이면 RequestMapping. ViewResolver는 안보이지만 동작

DispatcherServlet-Servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

	<!-- HandlerMapping -->
	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="mappings">
			<props>
				<prop key="/main.do">main</prop>
				<prop key="/login.do">login</prop>
				<prop key="/logout.do">logout</prop>
				<prop key="/insertBoardPage.do">insertBoardPage</prop>
				<prop key="/insertBoard.do">insertBoard</prop>
			</props>
		</property>
	</bean>
	
	<!-- Controller -->
	<bean class="com.spring.view.controller.MainController" id="main" />
	<bean class="com.spring.view.controller.LoginController" id="login" />
	<bean class="com.spring.view.controller.LogoutController" id="logout" />
	<bean class="com.spring.view.controller.InsertBoardPageController" id="insertBoardPage" />
	<bean class="com.spring.view.controller.InsertBoardController" id="insertBoard" />

	<!-- ViewResolver -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/" />
		<property name="suffix" value=".jsp" />
	</bean>
	
</beans>

xml에서의 HandlerMapping, Controller,와 ViewResolver

profile
이진 입니다

0개의 댓글