【问题标题】:getParameter() is returning null value with post methodgetParameter() 使用 post 方法返回空值
【发布时间】:2015-08-02 15:07:08
【问题描述】:

我对此做了很多交叉引用,但我不明白我哪里出错了。我在上传文件时使用此代码。我可以成功上传文件,但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");
...

【问题讨论】:

标签: java jsp


【解决方案1】:

request.getParameter() 不支持多部分请求。它总是返回 null。您需要使用FileUpload。 也看http://javakart.blogspot.in/2012/11/file-upload-example-using-servlet.htmlhttp://www.tutorialspoint.com/servlets/servlets-file-uploading.htm

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-18
  • 1970-01-01
  • 2012-07-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多