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

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

【现象】

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)

【解决方法】

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

修改为:

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

相关文章