为什么此代码返回此错误?
代码:
@Path("/site/resource/upload")
@Local
@Stateless
public class TreeResourceResourcesUpload extends TreeBaseResources {
@POST
@Produces( MediaType.APPLICATION_JSON )
@Consumes( MediaType.MULTIPART_FORM_DATA )
public TreeNodeTO uploadResource(@Context HttpServletRequest request) throws IOException, ServletException {
for (Part part : request.getParts()) {
System.out.println(part.getName());
}
return null;
}
}
错误:
Caused by: java.lang.IllegalStateException: PWC4016: Request.getParts is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml
系统:Glassfish 3.1.2.2 和 Sun JDK 7
谢谢!