今天踩了个大坑,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;
}
跑起来之后访问这个接口,报错:
查了好几遍代码和配置文件都没找到问题,最后发现是ModelAndView这个类的包导入错了,导入成了:
import org.springframework.web.portlet.ModelAndView;
而正确的应该是用:
import org.springframework.web.servlet.ModelAndView;
觉得自己好蠢,总被这种小问题困住好久,好蠢啊
@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;
觉得自己好蠢,总被这种小问题困住好久,好蠢啊
相关文章推荐
- jst获取不到springmvc中model数据
- java虚拟机参数设置 jvm参数设置
- java虚拟机参数设置 jvm参数设置
- jmeter java sampler测试java接口(一)javatest解读
- RxJava初级解析(一)
- Java NIO:浅析I/O模型
- [贪心算法]java解决背包问题
- java循环练习:用户输入一个10以内的数字,通过运算求出该数字的阶乘
- 希尔排序(Java语言描述)
- Java基础之Set
- Java并发:三种线程抽象以及线程执行
- ubuntu14.04安装jdk
- Java词频统计算法(使用单词树)
- JAVA第三周随笔
- Java socket中关闭IO流后,发生什么事?(以关闭输出流为例)
- springmvc 原理图文解释
- myeclipse断点调试
- Java内部类详解
- java循环练习:由输入的值决定循环的执行次数,循环变量默认从1开始
- Java基础------知识点整理(四)-----final关键字