javax.servlet.ServletException:Circular view path [test]: would dispatch back to the current handler

异常描述

Spring MVC当配置好Controller之后,直接访问某个控制器,如

@RequestMapping(value = "/test", method = RequestMethod.GET)
public void test() {
    log.info("测试");
}

正常来说后台会打印,客户端是404,毕竟没有返回。但是现在抛出这个错误

javax.servlet.ServletException: Circular view path [test]: 
		would dispatch back to the current handler URL

解决

  1. 没有定义视图解析器,可以定义一个,比如JSP的

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/"/>
    <property name="suffix" value=".jsp"/>
bean>

这个需要导入一个JSTL包(Java Standard Tag Libaray)
不然报错 java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config


<dependency>
    <groupId>javax.servletgroupId>
    <artifactId>jstlartifactId>
    <version>1.2version>
dependency>

你可能感兴趣的:(SSM,框架开发)