當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。