如何使用 JSP
和 Spring MVC
在文件对话框中设置可接受的扩展名?我就是这样做的:
<form:form method="post" enctype="multipart/form-data"
modelAttribute="uploadedFile" action="fileUpload">
<table>
<tr>
<td>Upload File:</td>
<td><input type="file" name="file" /></td>
<td style="color: red; font-style: italic;"><form:errors
path="file" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Upload" /></td>
<td></td>
</tr>
</table>
</form:form>
我可以用 Spring 做这样的事情吗:
<input type="file" name="file" ext="xml, txt"/>
最佳答案
试试这个..
<html>
<body>
<input type="file" name="fi" accept="text/xml, text/plain"/>
</body>
</html>
你不需要 spring 来做到这一点。这只是简单的 HTML。
关于java - 文件对话框中可接受的扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21601993/