Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 GlassFish 4 或 Tyrus (WebSocket 1.0 API) 中,Decoder 具有 willDecode 方法来确定此 Decoder 是否会解码。
但是 Encoder 没有 willEncode 方法。WebSocket API 如何确定编码器。Encoder 应该有 willEncode 方法吗?
我从 Arun Gupta 那里得到了答复。
他说解码器需要窥视消息并做出决定。编码器知道要编码的 POJO。
然后我明白了。
Endpoint 不能为每个 Endpoint 注册文本消息或二进制消息的两个 MessageHandler,但可以为文本消息和二进制消息分别注册一个 MessageHandler。然后 Endpoint 处理 2 种 POJO 类型,因此 WebSocket 实现可以根据 POJO 类型决定 Encoder。
谢谢你。
我有一个应用程序,其中有一个用于表单输入的模板。
由于页面上将有相同输入/标签的多个版本,因此输入 ID 不能被硬编码。
相反,我构建了一个用于绑定 attr 的函数('id' 用于输入,'for' 用于标签)。
这在 Chrome 和 IE9 中效果很好,但在 IE8 和 IE7 中失败。
我有一个标签和输入:<