循环视图路径-从IDE运行webapp

时间:2019-07-11 11:11:38

标签: java spring

我有一个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错误?

0 个答案:

没有答案