java分布式部署的时候执行request.getSession().setAttribute("VO",Object);时报setAttribute: Non-serializable attribute异常,这的问题有如下几种解决方法
1、在你的项目不要经过分布试部署的时候比较简单:去掉web.xml中的 <distributable/> 就行了。
2、在你的项目要通过分部试部署的时候,首先是要将你写入的绑定对象进行序列化,再进行入request.getSession().setAttribute("VO",绑定对象)操作。其方法是:
让绑定类实现一下序列化接口即 implements java.io.Serializable。
注意:
这样在不管是在分布试部署还是在非分布试部署都不会有问题了。不过序列化之后会让服务器的负载加重,没有必要的话不建议序列化。