Skip to content

Spring MVC 설정  #7

Description

@dev-xong

servlet-context.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" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <mvc:annotation-driven></mvc:annotation-driven>

    <mvc:resources mapping="/resources/**" location="/resources/"></mvc:resources>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views"></property>
        <property name="suffix" value="*.jsp"></property>
    </bean>
</beans>
<mvc:annotation-driven></mvc:annotation-driven>
  • 스프링 MVC 설정을 annotaion 기반으로 처리한다는 의미
  • 스프링 MVC의 여러 객체들을 자동으로 스프링 빈(Bean)으로 등록하게 하는 기능
<mvc:resources mapping="/resources/**" location="/resources/"></mvc:resources>
  • 이미지나 html 파일과 같이 정적인 파일의 경로를 지정
  • /resources 경로로 들어오는 요청은 정적파일을 요구하는 것으로 스프링 MVC에서 처리하지 않음을 의미
  • location의 속성 값은 webapp 폴더에 만들어둔 폴더를 의미
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

InternalResourceViewResolver

  • 스프링MVC에서 제공하는 뷰(view)를 어떻게 결정하는지에 대한 설정을 담당

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions