我用Gradle的春季启动给了我一个null的modelAndView对象

问题描述 投票:0回答:2

所以这是我的第一个带有spring boot和Gradle的web项目,我已经完成了与spring boot开始时提到的相同的步骤。即使构建过程正常并且依赖关系似乎也可以,但是每当我调用controller / firstapp时,我都会得到一个空视图,即使我尝试返回一个字符串,我也有一个Whitelabel错误页面。这是我的项目。

项目目录图片:

enter image description here

测试控制器:

enter image description here

主要课程:

enter image description here

application.properties :

enter image description here

build.gradle:

enter image description here

enter image description here

java spring-boot gradle
2个回答
0
投票

尝试使用spring.mvc.view.suffix属性中的* .html而不是.html


0
投票

问题是由于我的目录配置错误,spring-boot无法从application.properties读取Viewresolver,并且控制器类也应位于主springapplication下的子目录中。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.