org.springframework.web.servlet.ModelAndView.isReference()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.springframework.web.servlet.ModelAndView.isReference()方法的一些代码示例,展示了ModelAndView.isReference()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ModelAndView.isReference()方法的具体详情如下:
包路径:org.springframework.web.servlet.ModelAndView
类名称:ModelAndView
方法名:isReference

ModelAndView.isReference介绍

[英]Return whether we use a view reference, i.e. trueif the view has been specified via a name to be resolved by the DispatcherServlet via a ViewResolver.
[中]返回是否使用视图引用,即如果已通过DispatcherServlet通过ViewResolver解析的名称指定视图,则返回True。

代码示例

代码示例来源:origin: spring-projects/spring-framework

private String formatView() {
  return isReference() ? "\"" + this.view + "\"" : "[" + this.view + "]";
}

代码示例来源:origin: org.springframework/spring-webmvc

private String formatView() {
  return isReference() ? "\"" + this.view + "\"" : "[" + this.view + "]";
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void handleReturnValue(@Nullable 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();
      Assert.state(method != null, "No handler method");
      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());
  }
}

代码示例来源:origin: org.springframework/spring-webmvc

@Override
public void handleReturnValue(@Nullable 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();
      Assert.state(method != null, "No handler method");
      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());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@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());
}

代码示例来源:origin: org.springframework/spring-webmvc

@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());
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Return diagnostic information about this model and view.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder("ModelAndView: ");
  if (isReference()) {
    sb.append("reference to view with name '").append(this.view).append("'");
  }
  else {
    sb.append("materialized View is [").append(this.view).append(']');
  }
  sb.append("; model is ").append(this.model);
  return sb.toString();
}

代码示例来源:origin: stormpath/stormpath-sdk-java

protected boolean shouldExecute(HttpServletRequest request, HttpServletResponse response,
                Object handler, ModelAndView modelAndView) {
  if (modelAndView == null || !modelAndView.isReference() || STORMPATH_JSON_VIEW_NAME.equals(modelAndView.getViewName())) {
    return false;
  }
  String viewName = modelAndView.getViewName();
  if (isRedirectOrForward(viewName)) {
    return false;
  }
  return true;
}

代码示例来源:origin: com.stormpath.spring/stormpath-spring-webmvc

protected boolean shouldExecute(HttpServletRequest request, HttpServletResponse response,
                Object handler, ModelAndView modelAndView) {
  if (modelAndView == null || !modelAndView.isReference() || STORMPATH_JSON_VIEW_NAME.equals(modelAndView.getViewName())) {
    return false;
  }
  String viewName = modelAndView.getViewName();
  if (isRedirectOrForward(viewName)) {
    return false;
  }
  return true;
}

代码示例来源:origin: spring-projects/spring-batch-admin

if (modelAndView.isReference()) {

代码示例来源:origin: org.springframework.batch/spring-batch-admin-resources

if (modelAndView.isReference()) {

代码示例来源:origin: riotfamily/riot

public View resolveView(HttpServletRequest request, ModelAndView mv)
    throws ViewResolutionException {
  if (mv.hasView() && !mv.isReference()) {
    return mv.getView();
  }
  return resolveView(request, mv.getViewName());
}

代码示例来源:origin: stormpath/stormpath-sdk-java

if (mav.isReference()) {

代码示例来源:origin: com.stormpath.spring/stormpath-spring-webmvc

if (mav.isReference()) {

代码示例来源:origin: apache/servicemix-bundles

@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());
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.springmvc

if (mv.isReference()) {

代码示例来源:origin: philwebb/springfaces

public boolean handle(Exception exception, SpringFacesContext context) throws Exception {
  ExternalContext externalContext = context.getFacesContext().getExternalContext();
  HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
  HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
  Object handler = context.getHandler();
  ModelAndView modelAndView = processHandlerException(request, response, handler, exception);
  if (modelAndView != null) {
    WebUtils.clearErrorRequestAttributes(request);
    if (modelAndView.isReference()) {
      String viewName = modelAndView.getViewName();
      Map<String, Object> model = modelAndView.getModel();
      Locale locale = FacesUtils.getLocale(context.getFacesContext());
      View view = this.dispatcher.resolveViewName(viewName, model, locale, request);
      modelAndView.setView(view);
    }
    context.render(modelAndView.getView(), modelAndView.getModel());
    return true;
  }
  return false;
}

代码示例来源:origin: org.springframework/org.springframework.web.portlet

mavResolver.resolveModelAndView(handlerMethod, handlerType, returnValue, implicitModel, webRequest);
  if (smav != ModelAndViewResolver.UNRESOLVED) {
    return (smav.isReference() ?
        new ModelAndView(smav.getViewName(), smav.getModelMap()) :
        new ModelAndView(smav.getView(), smav.getModelMap()));
ModelAndView mav = (smav.isReference() ?
    new ModelAndView(smav.getViewName(), smav.getModelMap()) :
    new ModelAndView(smav.getView(), smav.getModelMap()));

代码示例来源:origin: apache/servicemix-bundles

@Override
public void handleReturnValue(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) {
      if (((SmartView) view).isRedirectView()) {
        mavContainer.setRedirectModelScenario(true);
      }
    }
  }
  mavContainer.setStatus(mav.getStatus());
  mavContainer.addAllAttributes(mav.getModel());
}

代码示例来源:origin: org.springframework/spring-webmvc-portlet

mavResolver.resolveModelAndView(handlerMethod, handlerType, returnValue, implicitModel, webRequest);
  if (smav != ModelAndViewResolver.UNRESOLVED) {
    return (smav.isReference() ?
        new ModelAndView(smav.getViewName(), smav.getModelMap()) :
        new ModelAndView(smav.getView(), smav.getModelMap()));
ModelAndView mav = (smav.isReference() ?
    new ModelAndView(smav.getViewName(), smav.getModelMap()) :
    new ModelAndView(smav.getView(), smav.getModelMap()));

相关文章