如何解决sockjs 显示弹出窗口以在 IE 中保存 iframe.json 文件
我正在使用 spring-boot WebSocket 和 SockJsClient 进行通知。
用户在 IE 中登录系统后,将显示以下弹出窗口,
以下是 UI (ReactJS) 代码:
<SockJsClient url={"URL"} topics={["topicname"]} onMessage={this.showNotificationCount} ref={(client) => { this.clientRef = client }} options={["xhr-polling"]} />)
后端代码(Java spring-boot):
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer
{
@Override
public void configureMessageBroker(MessageBrokerRegistry config)
{
config.enableSimpleBroker("/topic","/user");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry)
{
registry.addEndpoint("/notification-websocket").setAllowedOrigins("*").withSockJS().setWebSocketEnabled(false);
}
}
弹出文件的内容:
我们可以禁用这个弹出窗口吗?
解决方法
来自官方文档的 this part,在副标题 4.3.3 的第 5 段中。 IE 8 和 9,它说:
Spring SockJS 支持还需要知道 SockJS 客户端的位置,因为它是从 iframe 加载的。默认情况下,iframe 设置为从 CDN 位置下载 SockJS 客户端。
我想这就是为什么你会得到 iframe 的下载信息。
将此选项配置为使用与应用程序同源的 URL 是个好主意。
因此您可以尝试像文档中的示例一样进行配置:
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/portfolio").withSockJS()
.setClientLibraryUrl("http://localhost:8080/myapp/js/sockjs-client.js");
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。