有人可以在使用Joy时让我知道如何为Jodd中的fileUploads配置maxFileSize吗?
即使在[joy.madvoc]部分中,我也尝试使用joy.props进行早期工作:
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中,因此它变为空。
答案 0 :(得分:1)
这是这样做的方法:
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
(在修复之后:)。