1 16 17 package org.springframework.web.servlet.mvc; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.springframework.validation.BindException; 23 import org.springframework.web.bind.ServletRequestDataBinder; 24 import org.springframework.web.servlet.ModelAndView; 25 26 51 public abstract class AbstractCommandController extends BaseCommandController { 52 53 56 public AbstractCommandController() { 57 } 58 59 63 public AbstractCommandController(Class commandClass) { 64 setCommandClass(commandClass); 65 } 66 67 72 public AbstractCommandController(Class commandClass, String commandName) { 73 setCommandClass(commandClass); 74 setCommandName(commandName); 75 } 76 77 78 protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) 79 throws Exception { 80 81 Object command = getCommand(request); 82 ServletRequestDataBinder binder = bindAndValidate(request, command); 83 BindException errors = new BindException(binder.getBindingResult()); 84 return handle(request, response, command, errors); 85 } 86 87 101 protected abstract ModelAndView handle( 102 HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) 103 throws Exception ; 104 105 } 106 | Popular Tags |