【问题标题】:hide part of the URL隐藏部分网址
【发布时间】:2018-10-25 19:01:30
【问题描述】:

我使用swagger2。我将它配置为在使用访问根路径时重定向到swagger-ui.html。

@Bean
public WebMvcConfigurer index() {
    return new WebMvcConfigurer() {
        @Override
        public void addViewControllers(ViewControllerRegistry registry) {
            registry.addRedirectViewController("/", "/swagger-ui.html");
        }
    };
}

正如我在 application.yml 中配置的 context-path 为 /api,现在当用户尝试访问 /api 时,他被重定向到 /api/swagger-ui.html。

但我根本不想显示swagger-ui.html,只留下/api。有没有办法做到这一点?

【问题讨论】:

    标签: spring-boot swagger-2.0


    【解决方案1】:

    您可以在登陆 html 页面上使用下面的 java 脚本

    <script>
        history.replaceState('data to be passed', 'Title of the page', "/api/");
    </script>
    

    【讨论】:

      猜你喜欢
      • 2016-02-17
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多