2017-08-25 45 views
0

我遇到了一个问题,当我在浏览器中导航到它时,swagger-ui试图下载index.html页面,而不是将它显示为html页面。无法弄清楚造成这种情况的原因。swagger-ui试图下载index.html

我在Spring中使用Swagger 1.3.4。

Spring配置:

@Configuration 
public class SwaggerConfig { 

@Bean 
public BeanConfig beanConfig() { 
    final BeanConfig beanConfig = new BeanConfig(); 
    beanConfig.setResourcePackage("com.example.rest.ws"); 
    beanConfig.setVersion("1.0"); 
    beanConfig.setBasePath("my-rest-services"); 
    beanConfig.setTitle("My API"); 
    beanConfig.setScan(true); 
    return beanConfig; 
} 

}

我然后对浏览器下面的要求:

https://example.com/my-rest-services/swagger-ui/index.html 

并尝试下载index.html文件。我检查响应头和有如下几点:

Accept-Ranges:bytes 
Age:2000 
Connection:Keep-Alive 
Content-Length:3467 
Content-Type:application/octet-stream 
Date:Fri, 24 Aug 2017 15:15:23 GMT 
Server:Apache-Coyote/1.1 

为什么会大摇大摆返回一个八位字节流内容类型?

回答

0

它是设置内容类型响应头的网络服务器。从你的响应头文件看来,apache是​​web服务器。

在Apache中,MIME类型和文件扩展名之间的映射存储在配置文件apache_home/conf/mime.types中,其中apache_home是在您的服务器上安装Apache的路径。

在文本编辑mime.types文件,并检查HTML文件的映射是否如下存在:

text/html的HTML HTM

其中,text/html的是MIME类型和HTML ,htm是文件扩展名。