【发布时间】:2014-02-24 19:48:38
【问题描述】:
我不知道如何使用getParts() 来保存参数。
我正在尝试将 4-5 个文本类型的输入与图像文件一起传递。我想将参数检索到字符串中,以便将它们添加到数据库中并将图像以 blob 格式保存在数据库中(而不是在服务器目录中)。
任何帮助将不胜感激。提前致谢
<form class="form-signin" action="createAlbum"
method="post" enctype="multipart/form-data" role="form">
<h2 class="form-signin-heading">
Add details to create an Album.
</h2>
<input type="text" name="aname"
class="form-control" placeholder="Album Name" required>
<input type="text" name="artists"
class="form-control" placeholder="Artist" required>
<input type="date" name="rdate"
class="form-control" placeholder="Release Date" required >
<input type="text" name="type"
class="form-control" placeholder="Genre" required >
<input type="text" name="price"
class="form-control" placeholder="Price">
<input type="file" name="picture"
class="form-control" placeholder="Picture" required >
<button class="btn btn-lg btn-primary btn-block"
type="submit">Add Album</button>
</form>
【问题讨论】:
-
您应该将您的
Servlet代码部分发布到您尝试检索参数的位置。如果不看一些代码,就没有真正的方法可以帮助您。如果您提供有关您尝试过的内容和结果的更多详细信息,也会有所帮助;是否有任何错误或异常?是否收到了一些参数,但没有收到其他参数?如果您提供更多详细信息,您将让那些想要帮助您更好地了解您的问题的人。 -
不确定您正在使用的解决方案,但您可能会发现这有点用 commons.apache.org/proper/commons-fileupload/using.html
-
我正在使用 getParts()。我不知道该怎么办。感谢@Leo,我使用了他们的库支持并完成了它。
标签: java html servlets multipartform-data