我有一个WebApp,如果将其构建为.war
并将其部署在TomcatServer中,则可以完美运行。
直接从IDE(Intellij)运行应用程序时,出现Circular view path
错误。
我的应用是这样的:
//From here start app
@SpringBootApplication
public class MainCore extends SpringBootServletInitializer{
public static void main(String[] args){ SpringApplication.run(MainCore.class, args); }
}
@Controller
@RequestMapping(value = "/")
public class DomainPage{
@RequestMapping(method = RequestMethod.GET)
public RedirectView domain() {
return new RedirectView("/login");
}
}
@Controller
@RequestMapping(value = "/login")
public class Login{
@RequestMapping(method = RequestMethod.GET)
public ModelAndView login(){
return new ModelAndView("login");
}
}
从IDE启动应用程序后,可以在浏览器中像这样localhost:8080
它在localhost:8080/login
处出现此错误:
Circular view path [login]: would dispatch back to the current handler URL [/login] again.
Check your ViewResolver setup!
(Hint: This may be the result of an unspecified view, due to default view name generation.)
这是在app-servlet.xml
中:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
login.jsp
位于目录rootapp/webcontent/WEB-INF/jsp/
为什么从IDE运行时出现Circular view path
错误?