Interceptor处理JFinal使用multipart/form-data时,先执行getFile
程序员文章站
2022-06-14 19:44:37
...
/**
* @Author: Tany
* @Date: 2019/4/28
*/
public class MultipartRequestHd implements FixedInterceptor {
@Override
public void intercept(Invocation inv) {
Controller controller = inv.getController();
HttpServletRequest request = controller.getRequest();
String contentType = request.getContentType();
if (contentType != null && contentType.startsWith("multipart/form-data")) {
controller.getFiles();
}
inv.invoke();
}
}
@Override
public void onFixedInterceptorConfig(FixedInterceptors fixedInterceptors) {
fixedInterceptors.add(new MultipartRequestHd());
fixedInterceptors.add(new ExceptionInterceptor());
}
上一篇: jfinal的批处理方法