Java Code Examples for org.springframework.web.servlet.ModelAndView#hasView()

The following examples show how to use org.springframework.web.servlet.ModelAndView#hasView() . These examples are extracted from open source projects. 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
@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
@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
@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);
}