Grails文件上传:渲染视图时如何设置输入文件的值

Grails file upload: how to set the value of the input file when the view is rendered

我有一个 upload 操作,它从视图上的表单接收文件。上传文件时完成验证。

如果文件无效,将再次显示视图,输入 type="file" 值应指向上传失败的文件。

这似乎不起作用:(视图中的代码)

<input type="file" name="opt" value="${params.opt}" />

这是呈现给用户的:

<input type="file" name="opt" value="org.springframework.web.multipart.commons.CommonsMultipartFile@c9b839">

有什么想法吗?

由于安全原因,这似乎是不可能的,如果服务器知道路径,则服务器可以访问可能包含私人信息的客户端文件。

更多信息:How to set a value to a file input in HTML?

我可能需要让用户再次 select 文件,或者做类似 AJAX 文件上传的操作:http://blog.teamtreehouse.com/uploading-files-ajax