當前位置: 首頁>>代碼示例>>Java>>正文


Java WebUtils.hasSubmitParameter方法代碼示例

本文整理匯總了Java中org.springframework.web.util.WebUtils.hasSubmitParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java WebUtils.hasSubmitParameter方法的具體用法?Java WebUtils.hasSubmitParameter怎麽用?Java WebUtils.hasSubmitParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.util.WebUtils的用法示例。


在下文中一共展示了WebUtils.hasSubmitParameter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkParameters

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Check whether the given request matches the specified parameter conditions.
 * @param params  the parameter conditions, following
 * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()}
 * @param request the current HTTP request to check
 */
public static boolean checkParameters(String[] params, HttpServletRequest request) {
	if (!ObjectUtils.isEmpty(params)) {
		for (String param : params) {
			int separator = param.indexOf('=');
			if (separator == -1) {
				if (param.startsWith("!")) {
					if (WebUtils.hasSubmitParameter(request, param.substring(1))) {
						return false;
					}
				}
				else if (!WebUtils.hasSubmitParameter(request, param)) {
					return false;
				}
			}
			else {
				boolean negated = separator > 0 && param.charAt(separator - 1) == '!';
				String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1);
				String value = param.substring(separator + 1);
				boolean match = value.equals(request.getParameter(key));
				if (negated) {
					match = !match;
				}
				if (!match) {
					return false;
				}
			}
		}
	}
	return true;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:37,代碼來源:ServletAnnotationMappingUtils.java

示例2: getHandlerMethodName

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
@Override
public String getHandlerMethodName(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
	String methodName = null;

	// Check parameter names where the very existence of each parameter
	// means that a method of the same name should be invoked, if any.
	if (this.methodParamNames != null) {
		for (String candidate : this.methodParamNames) {
			if (WebUtils.hasSubmitParameter(request, candidate)) {
				methodName = candidate;
				if (logger.isDebugEnabled()) {
					logger.debug("Determined handler method '" + methodName +
							"' based on existence of explicit request parameter of same name");
				}
				break;
			}
		}
	}

	// Check parameter whose value identifies the method to invoke, if any.
	if (methodName == null && this.paramName != null) {
		methodName = request.getParameter(this.paramName);
		if (methodName != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("Determined handler method '" + methodName +
						"' based on value of request parameter '" + this.paramName + "'");
			}
		}
	}

	if (methodName != null && this.logicalMappings != null) {
		// Resolve logical name into real method name, if appropriate.
		String originalName = methodName;
		methodName = this.logicalMappings.getProperty(methodName, methodName);
		if (logger.isDebugEnabled()) {
			logger.debug("Resolved method name '" + originalName + "' to handler method '" + methodName + "'");
		}
	}

	if (methodName != null && !StringUtils.hasText(methodName)) {
		if (logger.isDebugEnabled()) {
			logger.debug("Method name '" + methodName + "' is empty: treating it as no method name found");
		}
		methodName = null;
	}

	if (methodName == null) {
		if (this.defaultMethodName != null) {
			// No specific method resolved: use default method.
			methodName = this.defaultMethodName;
			if (logger.isDebugEnabled()) {
				logger.debug("Falling back to default handler method '" + this.defaultMethodName + "'");
			}
		}
		else {
			// If resolution failed completely, throw an exception.
			throw new NoSuchRequestHandlingMethodException(request);
		}
	}

	return methodName;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:63,代碼來源:ParameterMethodNameResolver.java

示例3: matchName

import org.springframework.web.util.WebUtils; //導入方法依賴的package包/類
@Override
protected boolean matchName(HttpServletRequest request) {
	return WebUtils.hasSubmitParameter(request, name);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:ParamsRequestCondition.java


注:本文中的org.springframework.web.util.WebUtils.hasSubmitParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。