本文介绍了在运行时更改CommonsMultipartResolver的maxUploadSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用进行文件上传。
I am using a CommonsMultipartResolver for file upload.
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" >
<!-- specify maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>
</bean
我希望能够在运行时更改其属性maxUploadSize以便管理员可以更改大小)。这样做的最好方法是什么?
I want to be able to change its property maxUploadSize at runtime (so that the size may be changed by the administrator). What is the best way to do this please?
推荐答案
您可以自动装载 CommonsMultipartResolver
在你的控制器中,并在运行时更新属性。
You can autowire CommonsMultipartResolver
in your controller and update the property there at runtime.
例如:
For example:
@Controller
public class MyController {
@Autowired
private CommonsMultipartResolver multipartResolver;
@RequestMapping(value = "/setMaxUploadSize", method = RequestMethod.GET)
public ModelAndView setMaxUploadSize() {
...
multipartResolver.setMaxUploadSize(5000);
...
}
}
这篇关于在运行时更改CommonsMultipartResolver的maxUploadSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!