Search in sources :

Example 1 with SmartView

use of org.springframework.web.servlet.SmartView in project spring-framework by spring-projects.

the class ModelAndViewMethodReturnValueHandler method handleReturnValue.

@Override
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
    if (returnValue == null) {
        mavContainer.setRequestHandled(true);
        return;
    }
    ModelAndView mav = (ModelAndView) returnValue;
    if (mav.isReference()) {
        String viewName = mav.getViewName();
        mavContainer.setViewName(viewName);
        if (viewName != null && isRedirectViewName(viewName)) {
            mavContainer.setRedirectModelScenario(true);
        }
    } else {
        View view = mav.getView();
        mavContainer.setView(view);
        if (view instanceof SmartView && ((SmartView) view).isRedirectView()) {
            mavContainer.setRedirectModelScenario(true);
        }
    }
    mavContainer.setStatus(mav.getStatus());
    mavContainer.addAllAttributes(mav.getModel());
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) View(org.springframework.web.servlet.View) SmartView(org.springframework.web.servlet.SmartView) SmartView(org.springframework.web.servlet.SmartView)

Example 2 with SmartView

use of org.springframework.web.servlet.SmartView in project tutorials by eugenp.

the class UserInterceptor method isRedirectView.

public static boolean isRedirectView(ModelAndView mv) {
    String viewName = mv.getViewName();
    if (viewName.startsWith("redirect:/")) {
        return true;
    }
    View view = mv.getView();
    return (view != null && view instanceof SmartView && ((SmartView) view).isRedirectView());
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) View(org.springframework.web.servlet.View) SmartView(org.springframework.web.servlet.SmartView) SmartView(org.springframework.web.servlet.SmartView)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)2 SmartView (org.springframework.web.servlet.SmartView)2 View (org.springframework.web.servlet.View)2