- /*
- * Copyright 2002-2004 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.bind;
- import javax.servlet.ServletRequest;
- import org.springframework.beans.MutablePropertyValues;
- import org.springframework.web.util.WebUtils;
- /**
- * PropertyValues implementation created from parameters in a ServletRequest.
- * Looks for all property values beginning with a certain prefix
- * and prefix separator.
- *
- * <p>This class is not immutable to be able to efficiently remove property
- * values that should be ignored for binding.
- *
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @version $Id: ServletRequestParameterPropertyValues.java,v 1.4 2004/03/18 02:46:15 trisberg Exp $
- */
- public class ServletRequestParameterPropertyValues extends MutablePropertyValues {
- /** Default prefix separator */
- public static final String DEFAULT_PREFIX_SEPARATOR = "_";
- /**
- * Create new ServletRequestPropertyValues using no prefix
- * (and hence, no prefix separator).
- * @param request HTTP Request
- */
- public ServletRequestParameterPropertyValues(ServletRequest request) {
- this(request, null, null);
- }
- /**
- * Create new ServletRequestPropertyValues using the default prefix
- * separator and the given prefix (the underscore character "_").
- * @param request HTTP Request
- * @param prefix prefix for properties
- */
- public ServletRequestParameterPropertyValues(ServletRequest request, String prefix) {
- this(request, prefix, DEFAULT_PREFIX_SEPARATOR);
- }
- /**
- * Create new ServletRequestPropertyValues supplying both prefix and prefix separator.
- * @param request HTTP Request
- * @param prefix prefix for properties
- * @param prefixSeparator Separator delimiting prefix (e.g. user) from property name
- * (e.g. age) to build a request parameter name such as user_age
- */
- public ServletRequestParameterPropertyValues(ServletRequest request, String prefix, String prefixSeparator) {
- super(WebUtils.getParametersStartingWith(request, (prefix != null) ? prefix + prefixSeparator : null));
- }
- }