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

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

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

ModelAndView.hasView介绍

[英]Indicate whether or not this ModelAndView has a view, either as a view name or as a direct View instance.
[中]指示此ModelAndView是否具有视图,作为视图名称或直接视图实例。

代码示例

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

/**
 * Do we need view name translation?
 */
private void applyDefaultViewName(HttpServletRequest request, @Nullable ModelAndView mv) throws Exception {
  if (mv != null && !mv.hasView()) {
    String defaultViewName = getDefaultViewName(request);
    if (defaultViewName != null) {
      mv.setViewName(defaultViewName);
    }
  }
}

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

/**
 * Do we need view name translation?
 */
private void applyDefaultViewName(HttpServletRequest request, @Nullable ModelAndView mv) throws Exception {
  if (mv != null && !mv.hasView()) {
    String defaultViewName = getDefaultViewName(request);
    if (defaultViewName != null) {
      mv.setViewName(defaultViewName);
    }
  }
}

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

if (!exMv.hasView()) {
  String defaultViewName = getDefaultViewName(request);
  if (defaultViewName != null) {

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

if (!exMv.hasView()) {
  String defaultViewName = getDefaultViewName(request);
  if (defaultViewName != null) {

代码示例来源:origin: kolorobot/thymeleaf-custom-layout

@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);
  if (Layout.NONE.equals(layoutName)) {
    return;
  }
  modelAndView.setViewName(layoutName);
  modelAndView.addObject(this.viewAttributeName, originalViewName);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-http-server-spring

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

代码示例来源:origin: info.aduna.appbase/aduna-appbase-webapp-base-core

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

代码示例来源:origin: org.openrdf.sesame/sesame-http-server-spring

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

代码示例来源: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: org.tinygroup/org.tinygroup.springmvc

if (!exMv.hasView()) {
  exMv.setViewName(getDefaultViewName(request));

代码示例来源:origin: org.apereo.cas/cas-server-support-oauth

if (!mv.isEmpty() && mv.hasView()) {
  return mv;

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

if (mv != null && !mv.hasView()) {
  mv.setViewName(getDefaultViewName(request));

相关文章