尝试编写多行文件然后下载:
def download() {
file.write("line1\n")
file.write("line2\n")
response.setHeader "Content-disposition", "attachment; filename=testalex.txt"
response.contentType = 'text-plain'
response.outputStream << file.text
response.outputStream.flush()
}
但是该文件仅显示第 2 行。这是什么原因?谢谢!