최대 1 분 소요

Servlet-context.xml 분석

  • 디스패처 서블릿을 위한 설정 파일이다

  • 정의된 자바빈을 디스패처 서블릿이 관리하는 컨텍스트에 로딩한다

  • spirng MVC 컴포넌트들을 디폴트설정을 통해 활성화

  • Spring MVC @Controller에 요청을 보내 처리하기 위한 HandlerMapping과 HandlerAdapter를 빈으로 등록한다

  • 컨트롤러(@Controller)에서는 @RequestMapping, @ExceptionHanedler 등과 같은 어노테이션을 통해 해당 기능을 사용할 수 있도록 한다

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



<annotation-driven />

spring annotiation을 활성화 하기 위해서 annotation-driven을 설정 해야한다


 


	<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>
    

ViewResilver:접두어, 접미어로 컨트롤러가 리턴하는 뷰의 이름을 해석한다


 

	<context:component-scan base-package="com.supermm.*" />

@Component, Service, @Repository, @Controller

어노테이션을 가진 자바빈들이 스캐닝을 할 수 있는 기본 패키지 경로


 

	<interceptors>
		<interceptor>

			<mapping path="/notices/**" />
			<beans:bean
				class="com.supermm.interceptor.LoginInterceptor" />

		</interceptor>
	</interceptors>

</beans:beans>

로그인 여부를 확인하기 위한 인터셉터이다

게시판쪽으로 들어오는 요청은 로그인이 되지 않았다면 로그인 화면으로 보낸다

댓글남기기