alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (AbstractCommandController.java)

This example Spring Framework source code file (AbstractCommandController.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

abstractcommandcontroller, abstractcommandcontroller, basecommandcontroller, bindexception, bindexception, exception, http, httpservletrequest, httpservletresponse, modelandview, modelandview, object, object, request, response, servlet, servletrequestdatabinder, string

The Spring Framework AbstractCommandController.java source code

/*
 * Copyright 2002-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.servlet.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;

/**
 * Abstract base class for custom command controllers.
 *
 * <p>Autopopulates a command bean from the request. For command validation,
 * a validator (property inherited from {@link BaseCommandController}) can be
 * used.
 *
 * <p>In most cases this command controller should not be used to handle form
 * submission, because functionality for forms is offered in more detail by the
 * {@link org.springframework.web.servlet.mvc.AbstractFormController} and its
 * corresponding implementations.
 *
 * <p>Exposed configuration properties
 * (<a href="BaseCommandController.html#config">and those defined by superclass):
* <i>none (so only those available in superclass).

* * <p>Workflow * (<a name="BaseCommandController.html#workflow">and that defined by superclass):
* * @author Rod Johnson * @author Juergen Hoeller * @see #setCommandClass * @see #setCommandName * @see #setValidator */ public abstract class AbstractCommandController extends BaseCommandController { /** * Create a new AbstractCommandController. */ public AbstractCommandController() { } /** * Create a new AbstractCommandController. * @param commandClass class of the command bean */ public AbstractCommandController(Class commandClass) { setCommandClass(commandClass); } /** * Create a new AbstractCommandController. * @param commandClass class of the command bean * @param commandName name of the command bean */ public AbstractCommandController(Class commandClass, String commandName) { setCommandClass(commandClass); setCommandName(commandName); } protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Object command = getCommand(request); ServletRequestDataBinder binder = bindAndValidate(request, command); BindException errors = new BindException(binder.getBindingResult()); return handle(request, response, command, errors); } /** * Template method for request handling, providing a populated and validated instance * of the command class, and an Errors object containing binding and validation errors. * <p>Call errors.getModel() to populate the ModelAndView model * with the command and the Errors instance, under the specified command name, * as expected by the "spring:bind" tag. * @param request current HTTP request * @param response current HTTP response * @param command the populated command object * @param errors validation errors holder * @return a ModelAndView to render, or <code>null if handled directly * @see org.springframework.validation.Errors * @see org.springframework.validation.BindException#getModel */ protected abstract ModelAndView handle( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception; }

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework AbstractCommandController.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.