当前位置: 首页>>代码示例>>Java>>正文


Java ModelAndViewContainer.removeAttributes方法代码示例

本文整理汇总了Java中org.springframework.web.method.support.ModelAndViewContainer.removeAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java ModelAndViewContainer.removeAttributes方法的具体用法?Java ModelAndViewContainer.removeAttributes怎么用?Java ModelAndViewContainer.removeAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.method.support.ModelAndViewContainer的用法示例。


在下文中一共展示了ModelAndViewContainer.removeAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
/**
 * Resolve the argument from the model or if not found instantiate it with
 * its default if it is available. The model attribute is then populated
 * with request values via data binding and optionally validated
 * if {@code @java.validation.Valid} is present on the argument.
 * @throws BindException if data binding and validation result in an error
 * and the next method parameter is not of type {@link Errors}.
 * @throws Exception if WebDataBinder initialization fails.
 */
@Override
public final Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	String name = ModelFactory.getNameForParameter(parameter);
	Object attribute = (mavContainer.containsAttribute(name) ?
			mavContainer.getModel().get(name) : createAttribute(name, parameter, binderFactory, webRequest));

	WebDataBinder binder = binderFactory.createBinder(webRequest, attribute, name);
	if (binder.getTarget() != null) {
		bindRequestParameters(binder, webRequest);
		validateIfApplicable(binder, parameter);
		if (binder.getBindingResult().hasErrors() && isBindExceptionRequired(binder, parameter)) {
			throw new BindException(binder.getBindingResult());
		}
	}

	// Add resolved attribute and BindingResult at the end of the model
	Map<String, Object> bindingResultModel = binder.getBindingResult().getModel();
	mavContainer.removeAttributes(bindingResultModel);
	mavContainer.addAllAttributes(bindingResultModel);

	return binder.convertIfNecessary(binder.getTarget(), parameter.getParameterType(), parameter);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:ModelAttributeMethodProcessor.java

示例2: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
/**
 * Resolve the argument from the model or if not found instantiate it with
 * its default if it is available. The model attribute is then populated
 * with request values via data binding and optionally validated
 * if {@code @java.validation.Valid} is present on the argument.
 * @throws BindException if data binding and validation result in an error
 * and the next method parameter is not of type {@link Errors}.
 * @throws Exception if WebDataBinder initialization fails.
 */
@Override
public final Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest request, WebDataBinderFactory binderFactory)
		throws Exception {

	String name = ModelFactory.getNameForParameter(parameter);
	Object attribute = (mavContainer.containsAttribute(name)) ?
			mavContainer.getModel().get(name) : createAttribute(name, parameter, binderFactory, request);

	WebDataBinder binder = binderFactory.createBinder(request, attribute, name);
	if (binder.getTarget() != null) {
		bindRequestParameters(binder, request);
		validateIfApplicable(binder, parameter);
		if (binder.getBindingResult().hasErrors()) {
			if (isBindExceptionRequired(binder, parameter)) {
				throw new BindException(binder.getBindingResult());
			}
		}
	}

	// Add resolved attribute and BindingResult at the end of the model

	Map<String, Object> bindingResultModel = binder.getBindingResult().getModel();
	mavContainer.removeAttributes(bindingResultModel);
	mavContainer.addAllAttributes(bindingResultModel);

	return binder.getTarget();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:ModelAttributeMethodProcessor.java

示例3: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest request, WebDataBinderFactory binderFactory) throws Exception {
	
	String name = ModelFactory.getNameForParameter(parameter);
	Object attribute = (mavContainer.containsAttribute(name)) ?
			mavContainer.getModel().get(name) : createAttribute(name, parameter, binderFactory, request);

	WebDataBinder binder = binderFactory.createBinder(request, attribute, name);
	if (binder.getTarget() != null) {
		//XXX: thinking 增加一个参数MethodParameter方便使用注解
		bindRequestParameters(binder, request,parameter);
		validateIfApplicable(binder, parameter);
		if (binder.getBindingResult().hasErrors()) {
			if (isBindExceptionRequired(binder, parameter)) {
				throw new BindException(binder.getBindingResult());
			}
		}
	}

	// Add resolved attribute and BindingResult at the end of the model

	Map<String, Object> bindingResultModel = binder.getBindingResult().getModel();
	mavContainer.removeAttributes(bindingResultModel);
	mavContainer.addAllAttributes(bindingResultModel);

	return binder.getTarget();
	
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:30,代码来源:NamespaceModelAttributeMethodProcessor.java


注:本文中的org.springframework.web.method.support.ModelAndViewContainer.removeAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。