Spring boot找不到template下面的html文件解决方法

来源:互联网 发布:中电数据在哪里 编辑:程序博客网 时间:2024/06/10 01:01

静态页面

spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下


/static

/public

/resources

/META-INF/resources


例如 resources建立一个static目录和index.htm静态文件,访问地址 http://localhost:8082/index.html



如果需要使用templates,thyleaf模版,首先Spring boot项目需要添加依赖,这样才能找到templates下面的*.html文件

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>

例如:






这样就可以使用:localhost:8082/crawler/here来访问这个aaa.html文件了。



端口8082是因为在application.properties文件里面设置server.port=8082,一般tomcat默认的端口是8080




阅读全文
0 1
原创粉丝点击