当前位置: 首页>>代码示例>>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;未经允许,请勿转载。