在Grails中上传带有UTF-8字符作为multipart/form-data
的文件时出现错误。
我正在使用下面的表格;
<form action="uploadPost" enctype="multipart/form-data; charset=utf-8" method="POST">
<label class="form-titles" for="csvList">Choose a file: </label>
<input type="file" id="csvList" name="csvList" style="width: 200px;"/>
<input type="submit"/>
在 Controller 中,我有:
def file = request.getFile('csvList')
这会导致错误:
ERROR [org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver] - No signature of method: org.springframework.security.wrapper.SavedRequestAwareWrapper.getFile() is applicable for argument types: (java.lang.String) values: [userList] Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getLocale(), getJSON()>
我认为Java中也是如此。
知道我在做什么错以及如何以多部分形式获取UTF-8字符集吗?
最佳答案
enctype="multipart/form-data"
不要在“enctype”属性中放入字符集。
关于grails - request.GetFile无法获取UTF-8字符集内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12901738/