1
记录一下,上传图片和显示图片的代码,前端页面:
enctype="multipart/form-data" method="post">
。2
后台servlet:protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.info("上传维修图片附件的servlet"); request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String path = request.getSession().getServletContext().getRealPath( "/upload/weixiuimg"); File filemulu =new File(path); //如果文件夹不存在则创建 if (!filemulu .exists()) { System.out.println("//不存在"); filemulu .mkdir();