-
스프링 레거시 - 파일업로드 위한 세팅JAVA/Egov 2020. 4. 1. 12:51
pom.xml
<!-- 2020.04.01 파일업로드 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.3</version> </dependency> <!-- 2020.04.01 파일업로드 --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency>
MultipartFilter 적용(web.xml)
<!-- 멀티파트필터 --> <filter> <filter-name>MultipartFilter</filter-name> <filter-class>org.springframework.web.multipart.support.MultipartFilter</filter-class> </filter> <filter-mapping> <filter-name>MultipartFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
MultipartResolver 등록 (common.xml)
<!-- MULTIPART RESOLVERS --> <!-- regular spring resolver --> <bean id="spring.RegularCommonsMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="100000000" /> <property name="maxInMemorySize" value="100000000" /> </bean>
allowCasualMultipartParsing 설정 (context.xml)방법1 %TOMCAT%/conf/context.xml - Tomcat 전체 적용
watchedResoruce는 신경 ㄴㄴ
<Context allowCasualMultipartParsing="true"> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- 캐시문제해결 --> <Resources cachingAllowed="true" cacheMaxSize="100000"></Resources> </Context>
form의 enctype="multipart/form-data"
controller의 @RequestMapping(value = "/insertCompleteForProblem.do", method = RequestMethod.POST, headers = ("content-type=multipart/*"))'JAVA > Egov' 카테고리의 다른 글
도로명주소 검색 API 적용 해보기 (0) 2020.04.07 Mybatis - Resultmap을 사용해서 VO 여러가지를 join쿼리 사용하여 매핑 (0) 2020.03.23 jsp파일 수정 후 서버 재시작 없이 새로고침으로 반영하기 (0) 2020.03.18