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

搭建了个基本的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;

觉得自己好蠢,总被这种小问题困住好久,好蠢啊

你可能感兴趣的:(今天踩了个大坑,springmvc的Circular view path)