本地主机重定向到另一个页面

时间:2020-06-01 20:45:12

标签: java spring spring-boot redirect localhost

我的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");
    }

}

我在做错什么吗?还是应该先在重定向到的页面上登录?

1 个答案:

答案 0 :(得分:1)

希望Here you can find your answer,基本上它在configuration