1 16 17 package org.springframework.web.bind; 18 19 import javax.servlet.ServletRequest ; 20 21 import org.springframework.beans.MutablePropertyValues; 22 import org.springframework.validation.BindException; 23 import org.springframework.web.multipart.MultipartHttpServletRequest; 24 25 63 public class ServletRequestDataBinder extends WebDataBinder { 64 65 70 public ServletRequestDataBinder(Object target) { 71 super(target); 72 } 73 74 79 public ServletRequestDataBinder(Object target, String objectName) { 80 super(target, objectName); 81 } 82 83 84 102 public void bind(ServletRequest request) { 103 MutablePropertyValues mpvs = new ServletRequestParameterPropertyValues(request); 104 if (request instanceof MultipartHttpServletRequest) { 105 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; 106 bindMultipartFiles(multipartRequest.getFileMap(), mpvs); 107 } 108 doBind(mpvs); 109 } 110 111 117 public void closeNoCatch() throws ServletRequestBindingException { 118 if (getBindingResult().hasErrors()) { 119 throw new ServletRequestBindingException( 120 "Errors binding onto object '" + getBindingResult().getObjectName() + "'", 121 new BindException(getBindingResult())); 122 } 123 } 124 125 } 126 | Popular Tags |