threw exception [Circular view path [index]: would dispatch back to the current handler URL [/index]

x33g5p2x  于2022-07-26 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(468)

【现象】

2022-07-23 14:54:31.191 [http-nio-8080-exec-9] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - [log,175] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular view path [index]: would dispatch back to the current handler URL [/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause
javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handler URL [/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
    at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:210)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:148)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:317)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

【解决方法】

@RequestMapping({"/index"})
   public ModelAndView index(String key) throws Exception {
      this.logger.debug("进入搜索页");
      ModelAndView mav = this.getModelAndView("index");
      mav.addObject("keyword", key);
      this.logger.debug("" + mav);
      return mav;
   }

修改为:

@RequestMapping({"/home"})
   public ModelAndView index(String key) throws Exception {
      this.logger.debug("进入搜索页");
      ModelAndView mav = this.getModelAndView("index");
      mav.addObject("keyword", key);
      this.logger.debug("" + mav);
      return mav;
   }

相关文章