本文整理了Java中org.springframework.web.servlet.ModelAndView.getModelMap()
方法的一些代码示例,展示了ModelAndView.getModelMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ModelAndView.getModelMap()
方法的具体详情如下:
包路径:org.springframework.web.servlet.ModelAndView
类名称:ModelAndView
方法名:getModelMap
[英]Return the underlying ModelMap instance (never null).
[中]返回基础ModelMap实例(从不为null)。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the model map. Never returns {@code null}.
* To be called by application code for modifying the model.
*/
public Map<String, Object> getModel() {
return getModelMap();
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Return the model map. Never returns {@code null}.
* To be called by application code for modifying the model.
*/
public Map<String, Object> getModel() {
return getModelMap();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Add an attribute to the model.
* @param attributeName name of the object to add to the model (never {@code null})
* @param attributeValue object to add to the model (can be {@code null})
* @see ModelMap#addAttribute(String, Object)
* @see #getModelMap()
*/
public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) {
getModelMap().addAttribute(attributeName, attributeValue);
return this;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Add an attribute to the model using parameter name generation.
* @param attributeValue the object to add to the model (never {@code null})
* @see ModelMap#addAttribute(Object)
* @see #getModelMap()
*/
public ModelAndView addObject(Object attributeValue) {
getModelMap().addAttribute(attributeValue);
return this;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Add all attributes contained in the provided Map to the model.
* @param modelMap a Map of attributeName -> attributeValue pairs
* @see ModelMap#addAllAttributes(Map)
* @see #getModelMap()
*/
public ModelAndView addAllObjects(@Nullable Map<String, ?> modelMap) {
getModelMap().addAllAttributes(modelMap);
return this;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a new ModelAndView given a view name and a model.
* @param viewName name of the View to render, to be resolved
* by the DispatcherServlet's ViewResolver
* @param model a Map of model names (Strings) to model objects
* (Objects). Model entries may not be {@code null}, but the
* model Map may be {@code null} if there is no model data.
*/
public ModelAndView(String viewName, @Nullable Map<String, ?> model) {
this.view = viewName;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a new ModelAndView given a View object and a model.
* <em>Note: the supplied model data is copied into the internal
* storage of this class. You should not consider to modify the supplied
* Map after supplying it to this class</em>
* @param view the View object to render
* @param model a Map of model names (Strings) to model objects
* (Objects). Model entries may not be {@code null}, but the
* model Map may be {@code null} if there is no model data.
*/
public ModelAndView(View view, @Nullable Map<String, ?> model) {
this.view = view;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a new ModelAndView given a view name, model, and HTTP status.
* @param viewName name of the View to render, to be resolved
* by the DispatcherServlet's ViewResolver
* @param model a Map of model names (Strings) to model objects
* (Objects). Model entries may not be {@code null}, but the
* model Map may be {@code null} if there is no model data.
* @param status an HTTP status code to use for the response
* (to be set just prior to View rendering)
* @since 4.3
*/
public ModelAndView(@Nullable String viewName, @Nullable Map<String, ?> model, @Nullable HttpStatus status) {
this.view = viewName;
if (model != null) {
getModelMap().addAllAttributes(model);
}
this.status = status;
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Add an attribute to the model using parameter name generation.
* @param attributeValue the object to add to the model (never {@code null})
* @see ModelMap#addAttribute(Object)
* @see #getModelMap()
*/
public ModelAndView addObject(Object attributeValue) {
getModelMap().addAttribute(attributeValue);
return this;
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Add all attributes contained in the provided Map to the model.
* @param modelMap a Map of attributeName -> attributeValue pairs
* @see ModelMap#addAllAttributes(Map)
* @see #getModelMap()
*/
public ModelAndView addAllObjects(@Nullable Map<String, ?> modelMap) {
getModelMap().addAllAttributes(modelMap);
return this;
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Add an attribute to the model.
* @param attributeName name of the object to add to the model (never {@code null})
* @param attributeValue object to add to the model (can be {@code null})
* @see ModelMap#addAttribute(String, Object)
* @see #getModelMap()
*/
public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) {
getModelMap().addAttribute(attributeName, attributeValue);
return this;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
@Nullable ModelAndView modelAndView) throws Exception {
this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request, response),
(modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Create a new ModelAndView given a view name and a model.
* @param viewName name of the View to render, to be resolved
* by the DispatcherServlet's ViewResolver
* @param model a Map of model names (Strings) to model objects
* (Objects). Model entries may not be {@code null}, but the
* model Map may be {@code null} if there is no model data.
*/
public ModelAndView(String viewName, @Nullable Map<String, ?> model) {
this.view = viewName;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Assert the total number of errors in the model.
*/
public <T> ResultMatcher errorCount(final int expectedCount) {
return result -> {
int actualCount = getErrorCount(getModelAndView(result).getModelMap());
assertEquals("Binding/validation error count", expectedCount, actualCount);
};
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Assert the model has errors.
*/
public <T> ResultMatcher hasErrors() {
return result -> {
int count = getErrorCount(getModelAndView(result).getModelMap());
assertTrue("Expected binding/validation errors", count != 0);
};
}
代码示例来源:origin: org.springframework/spring-webmvc
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
@Nullable ModelAndView modelAndView) throws Exception {
this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request, response),
(modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-13546
public void resolveExceptionModelAtArgument() throws Exception {
IllegalArgumentException ex = new IllegalArgumentException();
HandlerMethod handlerMethod = new HandlerMethod(new ModelArgumentController(), "handle");
this.resolver.afterPropertiesSet();
ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);
assertNotNull(mav);
assertEquals(1, mav.getModelMap().size());
assertEquals("IllegalArgumentException", mav.getModelMap().get("exceptionClassName"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void handleRequestPart() throws Exception {
MockMultipartHttpServletRequest multipartRequest = new MockMultipartHttpServletRequest();
multipartRequest.addFile(new MockMultipartFile("requestPart", "", "text/plain", "content".getBytes("UTF-8")));
HandlerMethod handlerMethod = handlerMethod("handleRequestPart", String.class, Model.class);
ModelAndView mav = handlerAdapter.handle(multipartRequest, response, handlerMethod);
assertNotNull(mav);
assertEquals("content", mav.getModelMap().get("requestPart"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void handleAndValidateRequestPart() throws Exception {
MockMultipartHttpServletRequest multipartRequest = new MockMultipartHttpServletRequest();
multipartRequest.addFile(new MockMultipartFile("requestPart", "", "text/plain", "content".getBytes("UTF-8")));
HandlerMethod handlerMethod = handlerMethod("handleAndValidateRequestPart", String.class, Errors.class, Model.class);
ModelAndView mav = handlerAdapter.handle(multipartRequest, response, handlerMethod);
assertNotNull(mav);
assertEquals(1, mav.getModelMap().get("error count"));
}
代码示例来源:origin: spring-projects/spring-framework
ModelMap model = mav.getModelMap();
内容来源于网络,如有侵权,请联系作者删除!