设置了Spring boot的项目的默认首页,但是访问不到页面
设置如下
首页路径
POM.xml
访问后
Spring boot 默认就有首页的设定,在static 或者resources 下面放置一个index.html文件 访问 ip+端口号就可以直接跳转到该页面,不需要任何其他设置
重定向的是后端的路径,你这是前端的页面.当你设置这个的时候,spring mvc 会去后台找相应的路径,匹配.如果你想返回一个页面,你应该设置一个路径,在路径
里面再返回页面.这需要在controller里面写一个接口,返回一个页面.
目录static加上试试
forward改成redirect
直接在web.xml中编写你要跳转的规则,然后在controller那里对应规则重定向到你要的页面。
application.properties 加入:
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.html
spring.resources.static-locations=classpath:/static/