Springboot怎么访问html页面
2018-03-21 16:08
721 查看
1. 在原有的项目resouces目录下创建static包,并在static下创建pages,然后在pages包下hello.html.
这时你会发现hello.html并没有在static中,它跑哪去了呢?打开src下的webapp,发现有一个hello.htm,删除web.xml,并将hello.html用鼠标左键移到static目录下;hello.html代码:<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Insert title here</title>
</head>
<body>
<h1>springboot访问第一个html页面</h1>
</body>
</html>
1.1. 创建springboot配置文件application.roperties
在创建resouces目录下创建application.properties,创建完成后会出现一个绿叶图标打开application.properties,添加如下配置:spring.mvc.view.prefix=/pages/
spring.mvc.view.suffix=.html
1.2.修改SpringBootController中的代码
将改成
1.3.测试
启动Appliction中的main方法(springboot应用的入口)打开浏览器访问http://localhost:8080/hello
效果:
测试成功
相关文章推荐
- SpringBoot直接访问HTML页面
- springboot如何使用thymeleaf模板访问html页面
- springboot demo写好之后再去写一个controller,怎么也访问不到页面
- Springboot访问项目怎么不用加项目名?
- spring boot 使用velocity、freeMarker模板创建html页面返回给前端
- 关于springboot访问页面
- Spring Boot类上注解@RequestMapping失效访问不到页面
- Swagger使用及Springfox+SpringBoot访问http://localhost:8080/swagger-ui.htmlui404
- Spring boot项目中展示HTML页面效果
- 访问不存在的Thymeleaf 资源时使页面转向 404,而不是500 (Spring Boot)
- springboot 项目使用freemarker 配置之后,访问静态和动态页面的方法
- springBoot 学习记录(四)- 访问jsp页面
- springboot--页面访问拦截器
- Spring boot JSP访问页面显示Whitelabel Error Page
- SpringBoot打包成jar在服务器上无法访问JSP页面问题
- springboot访问jsp页面
- springboot + freemarker 返回html页面基本操作(初学者)
- SpringBoot项目如何访问jsp页面
- 通过SpringBoot进入HTML页面
- Springboot无法访问static的html