【发布时间】:2012-03-28 11:37:11
【问题描述】:
我正在这样做
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
MultipartFile multipartFile = null;
File destFile = new File(
"/home/stas/eclipse/" + request.getParameter("fileName"));
multipartFile.transferTo(destFile);
但我有例外
27.03.2012 20:39:45 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [springapp] in context with
path [/springapp] threw exception [Request processing failed;
nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
【问题讨论】:
-
您尚未将
multipartFile分配给任何内容。你怎么能指望它不会抛出 NPE?