我对此做了很多交叉引用,但我不明白我哪里出错了。我在上传文件时使用此代码。我可以成功上传文件,但 getParameter()
始终返回 null。
HTML 代码:
<form action="uploadingservlet" method="post"
enctype="multipart/form-data">
<input type="text" name="propername" >
<input type="file" name="file" >
<input type="submit" value="Upload File" />
</form>
Servlet 代码:
public class uploadingservlet extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException {
isMultipart = ServletFileUpload.isMultipartContent(request);
fname=request.getParameter("propername");
...
最佳答案
request.getParameter() 不支持多部分请求。它总是返回 null。您需要使用FileUpload 。 另请参阅http://javakart.blogspot.in/2012/11/file-upload-example-using-servlet.html http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm
关于java - getParameter() 使用 post 方法返回 null 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31773223/