spring mvc

Edit

Mapping 설정

<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
    <props>
      <prop key="...do">contentConroller</prop>
    </props>
  </property>
</bean>

View

Controller

MethodNameResolver

Model

Binder

MultipartResolver

파일첨부 처리 방법

  1. Request를 MultipartHttpServletRequest로 casting
  2. PropertyEditorSupport를 상속, setValue에서 value instaceof MultipartFile 이면 FileUploadUtil.uploadFormFile사용.

커스텀 태그

2.5

3.0

Validation

Converter

Spring web.xml

Listener 설정

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
WebApplicationContextUtils.getWebApplicationContext(getServlerContext());

DispatcherServlet 설정

web.xml에 설정

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>