форма в HTML, какКак получить файлы из HttpServletRequest в Java Servlet
...
<form method="post" action="/foobar">
<input type="file" name="attachment" />
<input type="text" name="foo" />
... other input fields
</form>
И 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
}
И я задаюсь
Есть ли способы, которые не используют сторонние библиотеки для получения файлов из объекта
HttpServletRequest
?Что возвращает
request.getParameter("attachement")
? Это имя файла или что-то еще?Будет ли бинарный вход храниться автоматически веб-контейнером в файловой системе или временно в памяти?
Здесь вы найдете: http://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp -servlet/2424824 # 2424824 –
Вы также можете посмотреть http://stackoverflow.com/questions/3831680/httpservletrequest-get-post-data, обрабатывая данные JSON. Если ваше вложение представлено URL-адресом, вам потребуется HTTPURLConnection для извлечения данных. –