关于Servlet上传文件的问题
Servlet中上传文件时,MultipartConfig的location怎么配置,使用的IDE是IDEA程序代码:
@MultipartConfig(location = "i:/") @WebServlet( "/UploadServlet3") public class UploadServlet3 extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); for (Part part : request.getParts()) { if(part.getName().startsWith("file")){ part.write(getFilename(part)); } } } private String getFilename(Part part){ String header=part.getHeader("Content-Disposition"); String filename=header.substring(header.indexOf("filename=\""),header.lastIndexOf("\"")); return filename; } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }