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


Java ModelAndViewContainer.getModel方法代码示例

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


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

示例1: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	ModelMap model = mavContainer.getModel();
	if (model.size() > 0) {
		int lastIndex = model.size()-1;
		String lastKey = new ArrayList<String>(model.keySet()).get(lastIndex);
		if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
			return model.get(lastKey);
		}
	}

	throw new IllegalStateException(
			"An Errors/BindingResult argument is expected to be declared immediately after the model attribute, " +
			"the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ErrorsMethodArgumentResolver.java

示例2: getModelAndView

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
private ModelAndView getModelAndView(ModelAndViewContainer mavContainer,
		ModelFactory modelFactory, NativeWebRequest webRequest) throws Exception {

	modelFactory.updateModel(webRequest, mavContainer);
	if (mavContainer.isRequestHandled()) {
		return null;
	}
	ModelMap model = mavContainer.getModel();
	ModelAndView mav = new ModelAndView(mavContainer.getViewName(), model);
	if (!mavContainer.isViewReference()) {
		mav.setView((View) mavContainer.getView());
	}
	if (model instanceof RedirectAttributes) {
		Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
		HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
		RequestContextUtils.getOutputFlashMap(request).putAll(flashAttributes);
	}
	return mav;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:RequestMappingHandlerAdapter.java

示例3: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	ModelMap model = mavContainer.getModel();
	if (model.size() > 0) {
		int lastIndex = model.size()-1;
		String lastKey = new ArrayList<String>(model.keySet()).get(lastIndex);
		if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
			return model.get(lastKey);
		}
	}

	throw new IllegalStateException(
			"An Errors/BindingResult argument is expected to be declared immediately after the model attribute, " +
			"the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:ErrorsMethodArgumentResolver.java

示例4: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	return mavContainer.getModel();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:MapMethodProcessor.java

示例5: handleReturnValue

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
		ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

	if (this.mavResolvers != null) {
		for (ModelAndViewResolver mavResolver : this.mavResolvers) {
			Class<?> handlerType = returnType.getContainingClass();
			Method method = returnType.getMethod();
			ExtendedModelMap model = (ExtendedModelMap) mavContainer.getModel();
			ModelAndView mav = mavResolver.resolveModelAndView(method, handlerType, returnValue, model, webRequest);
			if (mav != ModelAndViewResolver.UNRESOLVED) {
				mavContainer.addAllAttributes(mav.getModel());
				mavContainer.setViewName(mav.getViewName());
				if (!mav.isReference()) {
					mavContainer.setView(mav.getView());
				}
				return;
			}
		}
	}

	// No suitable ModelAndViewResolver...
	if (this.modelAttributeProcessor.supportsReturnType(returnType)) {
		this.modelAttributeProcessor.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
	}
	else {
		throw new UnsupportedOperationException("Unexpected return type: " +
				returnType.getParameterType().getName() + " in method: " + returnType.getMethod());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:ModelAndViewResolverMethodReturnValueHandler.java

示例6: updateModel

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
/**
 * Promote model attributes listed as {@code @SessionAttributes} to the session.
 * Add {@link BindingResult} attributes where necessary.
 * @param request the current request
 * @param mavContainer contains the model to update
 * @throws Exception if creating BindingResult attributes fails
 */
public void updateModel(NativeWebRequest request, ModelAndViewContainer mavContainer) throws Exception {
	ModelMap defaultModel = mavContainer.getDefaultModel();
	if (mavContainer.getSessionStatus().isComplete()){
		this.sessionAttributesHandler.cleanupAttributes(request);
	}
	else {
		this.sessionAttributesHandler.storeAttributes(request, defaultModel);
	}
	if (!mavContainer.isRequestHandled() && mavContainer.getModel() == defaultModel) {
		updateBindingResult(request, defaultModel);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ModelFactory.java

示例7: resolveArgument

import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	return mavContainer.getModel();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:MapMethodProcessor.java


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