Grails文件上传: how to set the value of the input file when the view is rendered

标签 grails grails-validation

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

如果文件无效,则再次显示 View 并输入 type="file" value 应该指向上传失败的文件。

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

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

这是呈现给用户的:
<input type="file" name="opt" value="org.springframework.web.multipart.commons.CommonsMultipartFile@c9b839">

有任何想法吗?

最佳答案

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

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

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

关于Grails文件上传: how to set the value of the input file when the view is rendered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30426186/

相关文章:

grails - 在 grails 中处理来自服务的错误

grails - 防止Grails 2.4.4接受无效日期

angularjs - Grails-Ionic-AngularJS-在这个Env中工作是个好主意吗?

grails - 在Grails自定义标签库中查找父标签

grails - Grails Spock测试特定异常

Grails 客户端验证

hibernate - 带有标准别名的 Grails GORM

在 Ubuntu 上运行应用程序时出现 Grails 依赖错误

spring - 无法解决Grails自定义验证程序问题

grails - 如何知道验证错误的原因