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
爲什麼會大搖大擺返回一個八位字節流內容類型?