HTML中的表单就像
...
<form method="post" action="/foobar">
<input type="file" name="attachment" />
<input type="text" name="foo" />
... other input fields
</form>
Run Code Online (Sandbox Code Playgroud)
而Servlet就像
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String attachment = request.getParameter("attachement");
String foo = request.getParameter("foo");
// get other parameters from the request
// and get the attachment file
}
Run Code Online (Sandbox Code Playgroud)
而且我在想
是否有任何方法不使用第三方库从HttpServletRequest对象中获取文件?
什么request.getParameter("attachement")回报?是文件名还是其他什么?
二进制输入是由Web容器自动存储在文件系统中还是暂时存储在内存中?
| 归档时间: |
|
| 查看次数: |
46627 次 |
| 最近记录: |