I tried to get and parse an XML file sent an upload from the GSP view. The file is correctly sent by the client but when I tried to parse it I have an exception.
------WebKitFormBoundaryPTpPKdL3WQWaPzJp--
*(The filename, directory name, or volume label syntax is incorrect). Stacktrace follows:
Message: ------WebKitFormBoundaryPTpPKdL3WQWaPzJp
Content-Disposition: form-data; name="file"; filename="myfile.xml"*
gsp:
<form enctype="multipart/form-data" method="post" action="uploadXml">
<input type="file" name="file" id="file" />
<input type="submit">
</form>
controller:
def project = new XmlParser().parse(request.reader.text)
On using request.getFile('file')
:
MultipartFile file = request.getFile('file')
I have another exception:
*| Error 2015-03-30 09:46:41,328 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /BOSWEBConfigurator/BOSOrder/uploadXml
No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [file]
Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON(). Stacktrace follows:
Message: No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [file]
Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON()*