亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? redirectview.java

?? spring framework 2.5.4源代碼
?? JAVA
字號:
/*
 * Copyright 2002-2008 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.view;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

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

import org.springframework.util.ClassUtils;

/**
 * <p>View that redirects to an absolute, context relative, or current request
 * relative URL, by default exposing all model attributes as HTTP query
 * parameters.
 *
 * <p>A URL for this view is supposed to be a HTTP redirect URL, i.e.
 * suitable for HttpServletResponse's <code>sendRedirect</code> method, which
 * is what actually does the redirect if the HTTP 1.0 flag is on, or via sending
 * back an HTTP 303 code - if the HTTP 1.0 compatibility flag is off.
 *
 * <p>Note that while the default value for the "contextRelative" flag is off,
 * you will probably want to almost always set it to true. With the flag off,
 * URLs starting with "/" are considered relative to the web server root, while
 * with the flag on, they are considered relative to the web application root.
 * Since most web applications will never know or care what their context path
 * actually is, they are much better off setting this flag to true, and
 * submitting paths which are to be considered relative to the web application
 * root.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @author Colin Sampaleanu
 * @author Sam Brannen
 * @see #setContextRelative
 * @see #setHttp10Compatible
 * @see #setExposeModelAttributes
 * @see javax.servlet.http.HttpServletResponse#sendRedirect
 */
public class RedirectView extends AbstractUrlBasedView {

	/** The default encoding scheme: UTF-8 */
	public static final String DEFAULT_ENCODING_SCHEME = "UTF-8";


	private boolean contextRelative = false;

	private boolean http10Compatible = true;

	private boolean exposeModelAttributes = true;

	private String encodingScheme = DEFAULT_ENCODING_SCHEME;


	/**
	 * Constructor for use as a bean.
	 */
	public RedirectView() {
	}

	/**
	 * Create a new RedirectView with the given URL.
	 * <p>The given URL will be considered as relative to the web server,
	 * not as relative to the current ServletContext.
	 * @param url the URL to redirect to
	 * @see #RedirectView(String, boolean)
	 */
	public RedirectView(String url) {
		super(url);
	}

	/**
	 * Create a new RedirectView with the given URL.
	 * @param url the URL to redirect to
	 * @param contextRelative whether to interpret the given URL as
	 * relative to the current ServletContext
	 */
	public RedirectView(String url, boolean contextRelative) {
		super(url);
		this.contextRelative = contextRelative;
	}

	/**
	 * Create a new RedirectView with the given URL.
	 * @param url the URL to redirect to
	 * @param contextRelative whether to interpret the given URL as
	 * relative to the current ServletContext
	 * @param http10Compatible whether to stay compatible with HTTP 1.0 clients
	 */
	public RedirectView(String url, boolean contextRelative, boolean http10Compatible) {
		super(url);
		this.contextRelative = contextRelative;
		this.http10Compatible = http10Compatible;
	}

	/**
	 * Create a new RedirectView with the given URL.
	 * @param url the URL to redirect to
	 * @param contextRelative whether to interpret the given URL as
	 * relative to the current ServletContext
	 * @param http10Compatible whether to stay compatible with HTTP 1.0 clients
	 * @param exposeModelAttributes whether or not model attributes should be
	 * exposed as query parameters
	 */
	public RedirectView(String url, boolean contextRelative, boolean http10Compatible, boolean exposeModelAttributes) {
		super(url);
		this.contextRelative = contextRelative;
		this.http10Compatible = http10Compatible;
		this.exposeModelAttributes = exposeModelAttributes;
	}


	/**
	 * Set whether to interpret a given URL that starts with a slash ("/")
	 * as relative to the current ServletContext, i.e. as relative to the
	 * web application root.
	 * <p>Default is "false": A URL that starts with a slash will be interpreted
	 * as absolute, i.e. taken as-is. If "true", the context path will be
	 * prepended to the URL in such a case.
	 * @see javax.servlet.http.HttpServletRequest#getContextPath
	 */
	public void setContextRelative(boolean contextRelative) {
		this.contextRelative = contextRelative;
	}

	/**
	 * Set whether to stay compatible with HTTP 1.0 clients.
	 * <p>In the default implementation, this will enforce HTTP status code 302
	 * in any case, i.e. delegate to <code>HttpServletResponse.sendRedirect</code>.
	 * Turning this off will send HTTP status code 303, which is the correct
	 * code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.
	 * <p>Many HTTP 1.1 clients treat 302 just like 303, not making any
	 * difference. However, some clients depend on 303 when redirecting
	 * after a POST request; turn this flag off in such a scenario.
	 * @see javax.servlet.http.HttpServletResponse#sendRedirect
	 */
	public void setHttp10Compatible(boolean http10Compatible) {
		this.http10Compatible = http10Compatible;
	}

	/**
	 * Set the <code>exposeModelAttributes</code> flag which denotes whether
	 * or not model attributes should be exposed as HTTP query parameters.
	 * <p>Defaults to <code>true</code>.
	 */
	public void setExposeModelAttributes(final boolean exposeModelAttributes) {
		this.exposeModelAttributes = exposeModelAttributes;
	}

	/**
	 * Set the encoding scheme for this view. Default is UTF-8.
	 */
	public void setEncodingScheme(String encodingScheme) {
		this.encodingScheme = encodingScheme;
	}


	/**
	 * Convert model to request parameters and redirect to the given URL.
	 * @see #appendQueryProperties
	 * @see #sendRedirect
	 */
	protected final void renderMergedOutputModel(
			Map model, HttpServletRequest request, HttpServletResponse response) throws IOException {

		// Prepare target URL.
		StringBuffer targetUrl = new StringBuffer();
		if (this.contextRelative && getUrl().startsWith("/")) {
			// Do not apply context path to relative URLs.
			targetUrl.append(request.getContextPath());
		}
		targetUrl.append(getUrl());
		if (this.exposeModelAttributes) {
			appendQueryProperties(targetUrl, model, this.encodingScheme);
		}

		sendRedirect(request, response, targetUrl.toString(), this.http10Compatible);
	}

	/**
	 * Append query properties to the redirect URL.
	 * Stringifies, URL-encodes and formats model attributes as query properties.
	 * @param targetUrl the StringBuffer to append the properties to
	 * @param model Map that contains model attributes
	 * @param encodingScheme the encoding scheme to use
	 * @throws UnsupportedEncodingException if string encoding failed
	 * @see #queryProperties
	 */
	protected void appendQueryProperties(StringBuffer targetUrl, Map model, String encodingScheme)
			throws UnsupportedEncodingException {

		// Extract anchor fragment, if any.
		String fragment = null;
		int anchorIndex = targetUrl.indexOf("#");
		if (anchorIndex > -1) {
			fragment = targetUrl.substring(anchorIndex);
			targetUrl.delete(anchorIndex, targetUrl.length());
		}

		// If there aren't already some parameters, we need a "?".
		boolean first = (getUrl().indexOf('?') < 0);
		Iterator entries = queryProperties(model).entrySet().iterator();
		while (entries.hasNext()) {
			if (first) {
				targetUrl.append('?');
				first = false;
			}
			else {
				targetUrl.append('&');
			}
			Map.Entry entry = (Map.Entry) entries.next();
			String encodedKey = urlEncode(entry.getKey().toString(), encodingScheme);
			String encodedValue =
					(entry.getValue() != null ? urlEncode(entry.getValue().toString(), encodingScheme) : "");
			targetUrl.append(encodedKey).append('=').append(encodedValue);
		}

		// Append anchor fragment, if any, to end of URL.
		if (fragment != null) {
			targetUrl.append(fragment);
		}
	}

	/**
	 * Determine name-value pairs for query strings, which will be stringified,
	 * URL-encoded and formatted by {@link #appendQueryProperties}.
	 * <p>This implementation filters the model through checking
	 * {@link #isEligibleProperty(String, Object)} for each element,
	 * by default accepting Strings, primitives and primitive wrappers only.
	 * @param model the original model Map
	 * @return the filtered Map of eligible query properties
	 * @see #isEligibleProperty(String, Object)
	 */
	protected Map queryProperties(Map model) {
		Map result = new LinkedHashMap();
		for (Iterator it = model.entrySet().iterator(); it.hasNext();) {
			Map.Entry entry = (Map.Entry) it.next();
			if (isEligibleProperty(entry.getKey().toString(), entry.getValue())) {
				result.put(entry.getKey().toString(), entry.getValue().toString());
			}
		}
		return result;
	}

	/**
	 * Determine whether the given model element should be exposed
	 * as a query property.
	 * @param key the key of the model element
	 * @param value the value of the model element
	 * @return whether the element is eligible as query property
	 */
	protected boolean isEligibleProperty(String key, Object value) {
		return (value != null &&
				(value instanceof String || ClassUtils.isPrimitiveOrWrapper(value.getClass())));
	}

	/**
	 * URL-encode the given input String with the given encoding scheme.
	 * <p>Default implementation uses <code>URLEncoder.encode(input, enc)</code>.
	 * @param input the unencoded input String
	 * @param encodingScheme the encoding scheme
	 * @return the encoded output String
	 * @throws UnsupportedEncodingException if thrown by the JDK URLEncoder
	 * @see java.net.URLEncoder#encode(String, String)
	 * @see java.net.URLEncoder#encode(String)
	 */
	protected String urlEncode(String input, String encodingScheme) throws UnsupportedEncodingException {
		return (input != null ? URLEncoder.encode(input, encodingScheme) : null);
	}

	/**
	 * Send a redirect back to the HTTP client
	 * @param request current HTTP request (allows for reacting to request method)
	 * @param response current HTTP response (for sending response headers)
	 * @param targetUrl the target URL to redirect to
	 * @param http10Compatible whether to stay compatible with HTTP 1.0 clients
	 * @throws IOException if thrown by response methods
	 */
	protected void sendRedirect(
			HttpServletRequest request, HttpServletResponse response, String targetUrl, boolean http10Compatible)
			throws IOException {

		if (http10Compatible) {
			// Always send status code 302.
			response.sendRedirect(response.encodeRedirectURL(targetUrl));
		}
		else {
			// Correct HTTP status code is 303, in particular for POST requests.
			response.setStatus(303);
			response.setHeader("Location", response.encodeRedirectURL(targetUrl));
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区不卡视频| 亚洲视频在线一区观看| 国产精品无圣光一区二区| 中文字幕中文字幕一区| 一区二区三区**美女毛片| 日韩高清一区二区| 国产在线一区二区| 一本色道a无线码一区v| 欧美丰满美乳xxx高潮www| 欧美精品一区二区三区在线 | 欧美aaa在线| 国产成人99久久亚洲综合精品| 91亚洲国产成人精品一区二区三| 欧美绝品在线观看成人午夜影视| 久久免费午夜影院| 一级做a爱片久久| 捆绑紧缚一区二区三区视频 | 依依成人综合视频| 久久精品国产久精国产| 99久久国产免费看| 91麻豆精品国产| 综合中文字幕亚洲| 蜜桃视频在线观看一区| 91在线观看免费视频| 日韩精品在线看片z| 亚洲人成网站在线| 免费观看久久久4p| 色久综合一二码| 久久精品人人做| 欧美高清www午色夜在线视频| 国产精品理伦片| 男女激情视频一区| 99国产精品99久久久久久| 欧美电影免费观看高清完整版 | 欧美体内she精高潮| 波多野结衣视频一区| 欧美精品123区| 中文字幕中文乱码欧美一区二区| 免费观看在线综合色| 色94色欧美sute亚洲线路一ni| www成人在线观看| 午夜精品爽啪视频| 91美女视频网站| 国产欧美一区二区在线观看| 三级亚洲高清视频| 91在线精品一区二区三区| 精品国免费一区二区三区| 亚洲福利视频导航| 99视频精品在线| 国产亚洲欧美日韩俺去了| 亚洲成人免费视| av电影天堂一区二区在线| 精品国产乱码久久久久久老虎| 亚洲第一搞黄网站| 一本大道av一区二区在线播放| 久久精品亚洲精品国产欧美kt∨| 青青国产91久久久久久| 欧美日韩国产一级片| 亚洲精品美腿丝袜| 不卡av免费在线观看| 国产亚洲一二三区| 韩日欧美一区二区三区| 日韩欧美在线影院| 免费日韩伦理电影| 91精品国产色综合久久不卡蜜臀| 亚洲综合激情另类小说区| 99re成人精品视频| 成人欧美一区二区三区小说 | 国产精品天干天干在线综合| 国产一区三区三区| 精品久久久久一区| 不卡一卡二卡三乱码免费网站| 日本va欧美va精品| 青青草一区二区三区| 国产一区二区三区在线观看免费视频 | www.99精品| 国产精品五月天| 亚洲午夜羞羞片| 精品亚洲成a人| 精品久久久久久久久久久久包黑料 | 三级欧美在线一区| 6080国产精品一区二区| 婷婷成人综合网| 欧美一区二区三区影视| 蜜桃一区二区三区四区| 精品久久免费看| 国产高清精品在线| 国产精品久久久一本精品| 不卡的av在线播放| 亚洲午夜一区二区| 91麻豆精品久久久久蜜臀| 美女一区二区三区| 久久综合狠狠综合久久综合88 | 一区视频在线播放| 91麻豆国产香蕉久久精品| 亚洲一区二区三区四区在线免费观看 | 91精品国产综合久久精品麻豆| 日韩电影在线免费看| 精品国产一区久久| 国产精品1024| 亚洲人成精品久久久久久| 欧美亚洲尤物久久| 蜜桃视频一区二区三区| 精品处破学生在线二十三| 成人性色生活片| 一区二区三区在线免费播放 | 精久久久久久久久久久| 欧美激情一区不卡| 色悠久久久久综合欧美99| 午夜精品在线看| 久久综合九色综合97婷婷女人 | 一区二区三国产精华液| 91精品视频网| 国产成人亚洲综合a∨婷婷| 亚洲男人的天堂在线aⅴ视频| 免费成人美女在线观看.| 久久久www成人免费无遮挡大片| 99久久精品国产观看| 亚洲成人av中文| 国产调教视频一区| 欧美亚洲禁片免费| 国产一区二区伦理片| 国产精品国产a| 欧美一区二区国产| 成人h版在线观看| 视频在线观看国产精品| 日本高清成人免费播放| 视频一区二区国产| 日韩理论片中文av| 日韩精品中文字幕在线一区| 99久久er热在这里只有精品15| 日韩精品成人一区二区三区| 国产精品视频在线看| 欧美一区二区三区精品| 99久久精品国产导航| 老司机精品视频导航| 亚洲人123区| 精品国产伦一区二区三区观看方式 | 日韩区在线观看| 91视频免费观看| 国产在线精品一区二区| 亚洲国产色一区| 国产精品久久久久精k8| 日韩情涩欧美日韩视频| 在线观看亚洲成人| 国产成人h网站| 美女视频黄 久久| 亚洲综合色视频| 欧美日韩黄色影视| www.一区二区| 国产一区欧美日韩| 五月天激情综合| 亚洲免费观看高清完整| 久久久一区二区| 这里只有精品电影| 91成人免费网站| 99国产精品久久| 国产成人午夜99999| 久久99热99| 日本系列欧美系列| 亚洲第一主播视频| 一区二区三区资源| 中文字幕在线不卡国产视频| 久久久www免费人成精品| 精品国产制服丝袜高跟| 欧美电影免费观看高清完整版| 国产**成人网毛片九色| 经典三级视频一区| 另类小说综合欧美亚洲| 日韩国产精品91| 偷窥国产亚洲免费视频| 亚洲精品视频一区二区| **欧美大码日韩| 中文字幕中文字幕在线一区| 中文字幕免费不卡在线| 欧美国产丝袜视频| 国产人成一区二区三区影院| 久久久噜噜噜久噜久久综合| 欧美成人午夜电影| 精品日韩一区二区三区| 日韩一区二区在线观看视频| 欧美一区二区三区四区五区| 制服丝袜亚洲精品中文字幕| 在线综合+亚洲+欧美中文字幕| 制服丝袜亚洲网站| www.成人在线| 91美女精品福利| 色美美综合视频| 91猫先生在线| 91黄色在线观看| 国产+成+人+亚洲欧洲自线| 国产伦精品一区二区三区免费迷| 国产精品久久久久久一区二区三区 | 国产日韩欧美麻豆| 国产亲近乱来精品视频 | 国内成人免费视频| 国产一区二区在线视频| 国产一区二区三区免费看| 久久99精品国产麻豆婷婷洗澡| 蜜桃视频一区二区三区在线观看|