您的位置:首页 > 编程语言 > Java开发

今天踩了个大坑,springmvc的Circular view path

2016-03-27 18:38 507 查看
搭建了个基本的springmvc的,写了一个controller,

@RequestMapping(value="/login" ,produces =
"text/html;charset=UTF-8")
public ModelAndView login(HttpSession
session,String account,String
password) throws UnsupportedEncodingException{
ModelAndView
mav = new ModelAndView();
mav.setViewName("main.jsp");
return
mav;
}
跑起来之后访问这个接口,报错:

javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/sale/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)


查了好几遍代码和配置文件都没找到问题,最后发现是ModelAndView这个类的包导入错了,导入成了:
import org.springframework.web.portlet.ModelAndView;
而正确的应该是用:

import org.springframework.web.servlet.ModelAndView;
觉得自己好蠢,总被这种小问题困住好久,好蠢啊
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: