springboot访问页面错误
在学习Spring Security时遇到如下两种错误
错误:Error resolving template [index], template might not exist or might not be accessible by any of the configured
Template Resolvers
错误:Circular view path [index]: would dispatch back to the current handler URL [/index] again. Check your ViewRe
solver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
自己总结了以下,主要原因有四种
-
application.yaml配置问题
# 关闭模板引擎,配置mvc视图解析器 spring: thymeleaf: cache: false mvc: view: suffix: .html prefix: classpath:/templates/ -
thymeleaf启动器问题
<!-- Thymeleaf依赖 --> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-java8time</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> -
静态资源问题
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> <include>**/*.XML</include> <include>**/*.yml</include> <include>**/*.html</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.XML</include> <include>**/*.yml</include> <include>**/*.html</include> </includes> </resource> </resources> </build> -
Handler注解使用错误
返回字符串注解:@ResponseBody
还历史以真诚,还生命以过程。 ——余秋雨
浙公网安备 33010602011771号