[英]Getting the error as invalidFormatException while upload using grails 2.3.7
DocumentController.groovy
def upload() {
def file =request.getFile('file')
def excelImportService
XSSFWorkbook book = new XSSFWorkbook(file.getInputStream());
Map CONFIG_BOOK_COLUMN_MAP = [
sheet:'Sheet1',
startRow: 1,
columnMap: [
//Col, Map-Key
'A':'Question',
'B':'SecType',
'C':'Option1',
'D':'Option2',
'E':'Option3',
'F':'Option4',
'G':'CorrectAnswer',
'H':'QuestionOrder'
]
]
//Iterate through bookList and create/persists your domain instances
def bookList = excelImportService.columns(book, CONFIG_BOOK_COLUMN_MAP)
在上傳具有相同格式的excel文件時出現錯誤:
2014-04-30 15:49:31,024 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - InvalidFormatException occurred when processing request: [POST] /Application/document/upload - parameters:**
upload: Upload
Package should contain a content type part [M1.13]. Stacktrace follows:
Message: Package should contain a content type part [M1.13]
Line | Method
代替:
XSSFWorkbook book = new XSSFWorkbook(file.getInputStream());
您應該使用:
Workbook book = WorkbookFactory.create(file.inputStream);
和
def excelImportService
應該從upload()
方法中刪除,而應作為DocumentController
類的屬性放置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.