spring RequestDataValueProcessor 源码

  • 2022-08-08
  • 浏览 (335)

spring RequestDataValueProcessor 代码

文件路径:/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RequestDataValueProcessor.java

/*
 * Copyright 2002-2016 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
 *
 *      https://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.reactive.result.view;

import java.util.Map;

import org.springframework.lang.Nullable;
import org.springframework.web.server.ServerWebExchange;

/**
 * A contract for inspecting and potentially modifying request data values such
 * as URL query parameters or form field values before they are rendered by a
 * view or before a redirect.
 *
 * <p>Implementations may use this contract for example as part of a solution
 * to provide data integrity, confidentiality, protection against cross-site
 * request forgery (CSRF), and others or for other tasks such as automatically
 * adding a hidden field to all forms and URLs.
 *
 * <p>View technologies that support this contract can obtain an instance to
 * delegate to via {@link RequestContext#getRequestDataValueProcessor()}.
 *
 * @author Rossen Stoyanchev
 * @since 5.0
 */
public interface RequestDataValueProcessor {

	/**
	 * Invoked when a new form action is rendered.
	 * @param exchange the current exchange
	 * @param action the form action
	 * @param httpMethod the form HTTP method
	 * @return the action to use, possibly modified
	 */
	String processAction(ServerWebExchange exchange, String action, String httpMethod);

	/**
	 * Invoked when a form field value is rendered.
	 * @param exchange the current exchange
	 * @param name the form field name
	 * @param value the form field value
	 * @param type the form field type ("text", "hidden", etc.)
	 * @return the form field value to use, possibly modified
	 */
	String processFormFieldValue(ServerWebExchange exchange, String name, String value, String type);

	/**
	 * Invoked after all form fields have been rendered.
	 * @param exchange the current exchange
	 * @return additional hidden form fields to be added, or {@code null}
	 */
	@Nullable
	Map<String, String> getExtraHiddenFields(ServerWebExchange exchange);

	/**
	 * Invoked when a URL is about to be rendered or redirected to.
	 * @param exchange the current exchange
	 * @param url the URL value
	 * @return the URL to use, possibly modified
	 */
	String processUrl(ServerWebExchange exchange, String url);

}

相关信息

spring 源码目录

相关文章

spring AbstractUrlBasedView 源码

spring AbstractView 源码

spring BindStatus 源码

spring DefaultRendering 源码

spring DefaultRenderingBuilder 源码

spring HttpMessageWriterView 源码

spring RedirectView 源码

spring Rendering 源码

spring RequestContext 源码

spring UrlBasedViewResolver 源码

0  赞