spring mvc 文件上传下载
加入依赖jar
1 | <dependency> |
增加 spring 配置1
2
3
4<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10248576"/><!--1M: 10248576-->
<property name="maxInMemorySize" value="10248576"/>
</bean>
上传
1 | "/upload") ( |
下载
1 | "/download") ( |
获取当前类文件的绝对路径
1 | MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath() |
获取当前jar包位置
1 | return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation() |