Java Code Examples for org.springframework.web.servlet.ModelAndView#hasView()
The following examples show how to use
org.springframework.web.servlet.ModelAndView#hasView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageHandlerInterceptor.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView mav) { HttpSession session = request.getSession(); if (session != null) { Message message = (Message) session.getAttribute(Message.ATTRIBUTE_KEY); if (message != null && !mav.getModelMap().containsKey(Message.ATTRIBUTE_KEY)) { mav.addObject(Message.ATTRIBUTE_KEY, message); } boolean shouldRemove = true; if (mav.hasView() && mav.getView() instanceof RedirectView) { shouldRemove = false; } if (mav.getViewName() != null && mav.getViewName().startsWith("redirect:")) { shouldRemove = false; } if (shouldRemove) { session.removeAttribute(Message.ATTRIBUTE_KEY); } } }
Example 2
Source File: ThymeleafLayoutInterceptor.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView == null || !modelAndView.hasView()) { return; } String originalViewName = modelAndView.getViewName(); if (isRedirectOrForward(originalViewName)) { return; } modelAndView.setViewName(DEFAULT_LAYOUT); modelAndView.addObject(DEFAULT_VIEW_ATTRIBUTE_NAME, originalViewName); }
Example 3
Source File: ThymeleafLayoutInterceptor.java From spring-boot-spring-loaded-java8-example with Apache License 2.0 | 5 votes |
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView == null || !modelAndView.hasView()) { return; } String originalViewName = modelAndView.getViewName(); if (isRedirectOrForward(originalViewName)) { return; } String layoutName = getLayoutName(handler); modelAndView.setViewName(layoutName); modelAndView.addObject(this.viewAttributeName, originalViewName); }