首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web开发 >

对象序列化存入文件有关问题

2013-06-19 
对象序列化存入文件问题String id customer.getId()String relativePath /WEB-INF/classes/customer

对象序列化存入文件问题

String id = customer.getId();
String relativePath = "/WEB-INF/classes/customerData/" + id
+ ".ser";
System.out.println("2");
String realPath = getServletContext().getRealPath(relativePath);
// 将对象序列化到文件中
FileOutputStream fos = new FileOutputStream(realPath);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(customer);

我用这段代码进行序列化的时候,E:\大二(下)\workplace1\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\6_1_3\WEB-INF\classes\customerData\4628514254221416162.ser (系统找不到指定的路径。)
会出现这样的错误,
求教!!! Java 序列化 web javabean
[解决办法]
请确认 /WEB-INF/classes/customerData/ 目录存在且一般用户可写

热点排行