使用Joy时,有人能告诉我如何在Jodd中配置fileUploads的最大FileSize吗?
我在joy.pops中尝试过,甚至在[joy.madvoc]部分也尝试过早期的工作:
madvocConfig.fileUploadFactory.maxFileSize=-1
但是运气不好:(
另一个问题是如何强制它,报告错误,就像没有它一样:
java.lang.NullPointerException
com.mycircle.action.CircleAction.add(CircleAction.java:78)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
jodd.madvoc.ActionRequest.invokeActionMethod(ActionRequest.java:256)
jodd.madvoc.ActionRequest.lambda$createExecutionArray$1(ActionRequest.java:226)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:79)
jodd.madvoc.interceptor.ActionInterceptor.apply(ActionInterceptor.java:38)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.joy.i18n.I18nInterceptor.intercept(I18nInterceptor.java:46)
jodd.madvoc.interceptor.ActionInterceptor.apply(ActionInterceptor.java:38)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.ActionRequest.lambda$createExecutionArray$0(ActionRequest.java:209)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.component.MadvocController.invoke(MadvocController.java:163)
jodd.madvoc.MadvocServletFilter.doFilter(MadvocServletFilter.java:109)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
jodd.decora.DecoraServletFilter.doFilter(DecoraServletFilter.java:144)
经过调试,我发现这是由于FileUploadFactory和AdaptiveFileUploadFactory中定义的100240字节的文件大小限制。
我有一个@In-FileUpload图片;在CircleAction中,它因此变为null。
以下是如何做到这一点:
- 从
Joy
到达Madvoc
- 在
Madvoc
中获取FileUploader
组件-它是一个新组件,只保存一个FileUploadFactory
实例 - 使用它:(
类似这样的东西:
public class MyWebApplication extends JoyContextListener {
@Override
protected JoddJoy createJoy() {
final JoddJoy joy = super.createJoy();
joy.withWebApp(webApp -> {
webApp.withRegisteredComponent(FileUploader.class, fileUploader -> {
AdaptiveFileUploadFactory adaptiveFileUploadFactory =
(AdaptiveFileUploadFactory) fileUploader.get();
adaptiveFileUploadFactory.setMaxFileSize(10000000);
});
});
return joy;
}
}
第二种方法是使用registerComponent
并简单地传递FileUploader
的实现。
Atm,不可能从madvoc配置中设置这个值,但我很快就会解决这个问题。不再有madvocConfig
,而是可以设置每个组件。因此,您可以这样做:fileUploader.maxFileSize
(修复后:(。