001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.bind.annotation; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023import java.lang.annotation.Target; 024 025/** 026 * Annotation that identifies methods which initialize the 027 * {@link org.springframework.web.bind.WebDataBinder} which 028 * will be used for populating command and form object arguments 029 * of annotated handler methods. 030 * 031 * <p>Such init-binder methods support all arguments that {@link RequestMapping} 032 * supports, except for command/form objects and corresponding validation result 033 * objects. Init-binder methods must not have a return value; they are usually 034 * declared as {@code void}. 035 * 036 * <p>Typical arguments are {@link org.springframework.web.bind.WebDataBinder} 037 * in combination with {@link org.springframework.web.context.request.WebRequest} 038 * or {@link java.util.Locale}, allowing to register context-specific editors. 039 * 040 * @author Juergen Hoeller 041 * @since 2.5 042 * @see org.springframework.web.bind.WebDataBinder 043 * @see org.springframework.web.context.request.WebRequest 044 */ 045@Target({ElementType.METHOD}) 046@Retention(RetentionPolicy.RUNTIME) 047@Documented 048public @interface InitBinder { 049 050 /** 051 * The names of command/form attributes and/or request parameters 052 * that this init-binder method is supposed to apply to. 053 * <p>Default is to apply to all command/form attributes and all request parameters 054 * processed by the annotated handler class. Specifying model attribute names or 055 * request parameter names here restricts the init-binder method to those specific 056 * attributes/parameters, with different init-binder methods typically applying to 057 * different groups of attributes or parameters. 058 */ 059 String[] value() default {}; 060 061}