【发布时间】:2020-09-20 06:08:41
【问题描述】:
我的 Spring Boot 项目遇到问题。当我运行应用程序并转到http://localhost:8086/ 时,它会重定向到http://localhost:8086/login,这不是我想要的页面。
这是我的 application.properties 文件的内容
#Database
spring.datasource.url=jdbc:mysql://localhost:3306/db_name
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.platform=mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#Html
spring.mvc.view.prefix=/public/
spring.mvc.view.suffix=.html
#Server
server.port=8086
我还添加了这个类,它应该打开上面属性中指定的 /public/ 文件夹中的 index.html 文件
public class WebAppConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index.html");
}
}
是我做错了什么还是我应该先在它重定向到的页面中登录?
【问题讨论】:
标签: java spring spring-boot redirect localhost