after enctype=“multipart/form-data” request not working

后端 未结 4 2018
你的背包
你的背包 2021-01-13 09:40

public class Relay extends HttpServlet {   
    @Override
    public void service(HttpServletRequest request, HttpServletResponse response)
    throws Servl         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 10:15

    Why do you need to add it then? Just keep it out.

    If you need it in order to upload a file by which you intend to add later on, then you should put @MultipartConfig annotation on your servlet, so that request.getParameter() will work and that all uploaded files can be retrieved by request.getPart().

    @WebServlet("/Relay")
    @MultipartConfig
    public class Relay extends HttpServlet {   
        // ...
    }
    

    See also:

    • How to upload files to server using JSP/Servlet?

提交回复
热议问题