且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Grails 2.3.7中上传文件时出错

更新时间:2023-11-19 19:45:52

[编辑-根据Burt的评论忽略此内容.它仅适用于Java/Spring]

[Edit - disregard this as per Burt's comment. It would only work in Java/Spring]

您可能必须将request对象转换为通常的MultipartHttpServletRequest:

You might have to cast your request object to the usual MultipartHttpServletRequest:

MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest) request
MultipartFile file = mhsr.getFile("attachments")

我猜测,由于Spring安全性似乎正在注入其自己的Servlet3SecurityContextHolderAwareRequestWrapper版本的request.

As Spring security appears to be injecting its own Servlet3SecurityContextHolderAwareRequestWrapper version of request, I'm guessing.