본문 바로가기

Development/Web & Server

[Spring Framework] Multipart file Upload 설정하기~!

1. pom.xml 설정

<dependency>

    <groupId>commons-fileupload</groupId>

    <artifactId>commons-fileupload</artifactId>

    <version>1.2.2</version>

</dependency>


   <dependency>

<groupId>commons-io</groupId>

<artifactId>commons-io</artifactId>

<version>2.4</version>

</dependency>


2. bean 등록~! 여러가지 설정이있지만 용량만 설정하였다.

<!-- Configure the multipart resolver -->

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

        <!-- one of the properties available; the maximum file size in bytes 2MB -->

        <property name="maxUploadSize" value="2000000"/>

    </bean>


3. 그리고 아래와 같이 사용하면 된다.~!