欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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