我們使用Spring MVC +的內置支持上傳文件。我想使用SpEL設置最大上傳大小。問題是這個值來自我們的數據庫。因此,在我們舊的應用程序代碼中,我們做了一次檢查,我們有以下上傳的文件:使用Spel + hibernate創建Bean
appManager.getAppConfiguration().getMaximumAllowedAttachmentSize();
然後我們檢查文件,看它是否大於該值,並根據尺寸進行。
我想,在我們的servlet配置以下調用像這樣來替換代碼:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver>
<property name="maxUploadSize" value="#{appManager.getAppConfiguration().getMaximumAllowedAttachmentSize()}" />
</bean>
的問題是,在初始化時我收到以下異常:
Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.hibernate.LazyInitializationException: could not initialize proxy - no Session
是有什麼辦法可以做到這一點?