我试图解析一个包含三个字段的CSV文件。
我的方法如下:
// this action is called when the user submits the upload form
def handle() {
CommonsMultipartFile file = request.getFile('filecsv')
if(file.empty) {
flash.error = g.message(code:'',default:'Empty cannot be uploaded')
} else {
InputStream fs = file.inputStream
fs.splitEachLine(',') { row ->
new Connection(
randomizedID: row[0],
token1: row[1],
token2: row[2]
).save(flush: true)
key++
println("Connection added")
}
}
}
查看输出,"连接添加"多次打印。 但是当我查看我的连接列表时,没有...