非序列化会话websocket java ee [英] non serializable session websocket java ee

查看:176
本文介绍了非序列化会话websocket java ee的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个ExchangeMoney类实现了Serializable接口。该类具有Session(javax.websocket.Session)属性。请参阅以下代码:

I write a ExchangeMoney class implements Serializable interface . This class has Session (javax.websocket.Session) property. See code below:

import javax.websocket.Session;
import javax.websocket.EncodeException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.Serializable;
...
public class ExchangeMoney implements Serializable {

    private static final long serialVersionUID = -4363184570862565571L;

    private static final Logger logger = Logger.getLogger("ExchangeMoney ");

    private Session session;

    ....
}

会话错误字段不可序列化。如何解决这个问题。

Error due to session field non serializable. How to resolve this problem.

推荐答案

查看这篇文章。
包含不可序列化部分的Java序列化

基本上,您可以扩展会话并实现可序列化并覆盖writeObject和readObject方法,并尝试持久化并读取您感兴趣的值。

Basically you can extend session and implement serializable and override writeObject and readObject methods and try to persist and read the values you are interested in.

这篇关于非序列化会话websocket java ee的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆