import org.apache.commons.io.FileUtils; @Controller public class AccountController extends BaseAction{ @RequestMapping("/add") public String add(@RequestParam("upFile") MultipartFile file, HttpServletRequest request) throws Exception { String filename = file.getOriginalFilename(); System.out.println(filename); ServletContext sc = request.getSession().getServletContext(); String dir = sc.getRealPath("/upload/"); String uploadImagePath = System.currentTimeMillis() + "-" + filename;
//上传 FileUtils.writeByteArrayToFile(new File(dir,uploadImagePath), file.getBytes()); return "redirect:/list"; } }