java multipartrequestwrapper,如何从Servlet3SecurityContextHolderAwareRequestWrapper中获取MultipartRequest...

I'm using Grails 2.4.3 and I have a with method set to post, but I'm not getting a MutlipartRequest in my controller action. Instead I'm getting a Servlet3SecurityContextHolderAwareRequestWrapper which has not getFile() method. I've tried casting, I've tried getting the request out of the wrapper with request.request, and I've tried a bunch of other things I've seen suggested to others with a similar problem, but still no dice. I'm sure I'm missing something simple. I tend to do that, but if anyone can point me in the right direction, I'd be very grateful.

Here's my form:

And here's my controller action:

def uploadSupplemental() {

MultipartRequest multipartRequest = request as MultipartRequest

def file = multipartRequest.getFile('supplementalData')

if (file){

flash.message = "File found!!"

} else {

flash.message = "File NOT found. :-( "

}

redirect action:'list'

}

And here's the error I get:

URI /app/upload/uploadSupplemental Class

groovy.lang.MissingMethodException Message No signature of method:

org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper.getFile()

is applicable for argument types: (java.lang.String) values:

[supplementalData] Possible solutions: getXML(),

getPart(java.lang.String), getAt(java.lang.String),

getAt(java.lang.String), getLocale(), getJSON()

解决方案

The following config property has to be set to true in Config.groovy in order to enable multipart requests.

grails.web.disable.multipart=true

Also make sure the user is authenticated (with @Secured) before the upload action.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值