Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3]
2017-04-02 18:54
627 查看
最近在学习使用springmvc,遇到了不少的坑,刚刚就遇到了一个,遂记录之
这是一段非常简单的代码,通过lhttp://localhost:8080/Spring_Demo/login3来访问,由前端控制器分发到这里来处理请求,本应该正常跳转的,但是遇到了bug
package fkit.controller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import fkit.domain.User;
@Controller
public class User3Controller {
private static final Log logger = LogFactory.getLog(User3Controller.class);
@ModelAttribute
public void userModel3(String loginname, String password, ModelAndView mv) {
logger.info("userModel3");
User user = new User();
user.setLoginname(loginname);
user.setPassword(password);
mv.addObject("user", user);
}
@RequestMapping(value = "/login3")
public ModelAndView login3(ModelAndView mv) {
User user = (User) mv.getModel().get("user");
user.setUsername("张三");
System.out.println(user);
mv.setViewName("/WEB-INF/content/result3.jsp");
return mv;
}
}
以下是错误信息
type Exception report
message Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3] again. Check your ViewResolver setup!
(Hint: This may be the result of an unspecified view, due to default view name generation.)
description The server encountered an internal error that prevented it from fulfilling this request.
exception
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.39 logs.
怎么也想不通为什么会是路径回环错误,经过仔细排查,发现是import org.springframework.web.portlet.ModelAndView;有问题,本应该是import org.springframework.web.servlet.ModelAndView;
这是一段非常简单的代码,通过lhttp://localhost:8080/Spring_Demo/login3来访问,由前端控制器分发到这里来处理请求,本应该正常跳转的,但是遇到了bug
package fkit.controller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import fkit.domain.User;
@Controller
public class User3Controller {
private static final Log logger = LogFactory.getLog(User3Controller.class);
@ModelAttribute
public void userModel3(String loginname, String password, ModelAndView mv) {
logger.info("userModel3");
User user = new User();
user.setLoginname(loginname);
user.setPassword(password);
mv.addObject("user", user);
}
@RequestMapping(value = "/login3")
public ModelAndView login3(ModelAndView mv) {
User user = (User) mv.getModel().get("user");
user.setUsername("张三");
System.out.println(user);
mv.setViewName("/WEB-INF/content/result3.jsp");
return mv;
}
}
以下是错误信息
HTTP Status 500 - Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
type Exception reportmessage Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3] again. Check your ViewResolver setup!
(Hint: This may be the result of an unspecified view, due to default view name generation.)
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145) org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.39 logs.
怎么也想不通为什么会是路径回环错误,经过仔细排查,发现是import org.springframework.web.portlet.ModelAndView;有问题,本应该是import org.springframework.web.servlet.ModelAndView;
相关文章推荐
- Circular view path [faults]: would dispatch back to the current handler URL [/pulsar/faults] again
- spring cloud 报[Circular view path [refundbbb]: would dispatch back to the current handler URL [/refu
- Circular view path [index]: would dispatch back to the current handler URL [/index] again.
- 《Springboot极简教程》问题解决:javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL
- Circular view path : would dispatch back to the current handler URL again. Check your ViewResolver s
- Spring boot 报错:Circular view path [...]: would dispatch back to the current handler
- Circular view path [home]: would dispatch back to the current handler URL [/home] again. Check your ViewResolver setup!
- spring boot would dispatch back to the current handler URL [/hello] again. Check your ViewResolver s
- Circular view path [...]: would dispatch back to the current handler
- Circular view path [...]: would dispatch back to the current handler
- javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handl
- centos 7 The path "" is not a valid path to the 3.10.0-229.el7.x86_64 kernel headers. Would you like to change it?
- iphone navigationController : wait for uialertview response before to quit the current view
- Spring自动映射mapped url path onto直接到了DefaultExceptionHandler
- 我的Android进阶之旅------>Android无第三方Jar包的源代报错:The current class path entry belongs to container ...的解决方法
- 我的Android进阶之旅------>Android无第三方Jar包的源代报错:The current class path entry belongs to container ...的解决方法
- Demo: Using Javascript / JQuery to play back user actions on the web
- VS.NET 2003 Error - The project you are trying to open is a Web project. You need to open it by specifying its URL path.
- 在springboot项目中引入swagger2时出现Circular view path [swagger-ui]
- [Tutor] how to change the current working directory path in ipython.