- 浏览: 109162 次
- 性别:
最新评论
-
douglas_lhs:
如果是搜索的话,是不是就要在action里面定义页面中的属性, ...
pager-taglib 的使用 -
wayer:
请问全景显示到底是怎么回事呢?
是不是先用软件做好全景图,然后 ...
PTViewer 全景显示 -
wangjian3q:
请问 为什么 我的 项目加了 urlrewrite
好像是没 ...
[转]UrlRewrite Filter -
MrLee23:
<context-param>
& ...
配置Spring 支持 Web session,request -
MrLee23:
给你代码整理下,你的看的有点别扭`
<context ...
配置Spring 支持 Web session,request
官方网站:http://xstream.codehaus.org/
测试了一下,的确十分方便。
java 代码
- public static void write() {
- XStream sm = new XStream();
- mytest t = new mytest();
- t.setName("moogle");
- t.setXb("男");
- try {
- FileOutputStream ops = new FileOutputStream(new File("C:\\111.xml"));
- sm.toXML(t, ops);
- ops.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void read() {
- XStream sm = new XStream(new DomDriver());
- try {
- FileInputStream ops = new FileInputStream(new File("C:\\111.xml"));
- mytest t = (mytest)sm.fromXML(ops);
- System.out.println(t.getName());
- ops.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
生成的XML文件内容:
xml 代码
- <mytest>
- <name>asd</name>
- <xb>男</xb>
- </mytest>
问题:
1.生成的xml文档没有<!---->
2.如果生成的文档中含有中文,比如上文代码中setXb("男")
在读取的时候会报
[Fatal Error] :4:7: Invalid byte 2 of 2-byte UTF-8 sequence.
请指教。
评论
19 楼
david3d
2007-07-16
Thanks. JJYAO.
I have replied you several days before but it was deleted by forum manager. Maybe because I pasted some redundant code lines in that reply : (
Your solution still cannot resolve my problem. But give me a good directive. I will try another way. Thanks again
I have replied you several days before but it was deleted by forum manager. Maybe because I pasted some redundant code lines in that reply : (
Your solution still cannot resolve my problem. But give me a good directive. I will try another way. Thanks again
18 楼
david3d
2007-07-12
I've tied the re-compile but still have problem. Maybe there's some other root cause for my case.
Anyway, Thanks for your reply.
Exception in thread "main" java.lang.ClassCastException: org.codehaus.jettison.json.JSONArray
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:93)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:130)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:134)
at com.thoughtworks.xstream.io.xml.StaxWriter.addAttribute(StaxWriter.java:86)
at com.thoughtworks.xstream.io.WriterWrapper.addAttribute(WriterWrapper.java:30)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:43)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
at com.thoughtworks.xstream.converters.collections.MapConverter.marshal(MapConverter.java:46)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:44)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:73)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:765)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:754)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:735)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:725)
at com.kss.immg.tec.ProdInfoActionTest.testDetachedObjectWithSetPropertyToJson(ProdInfoActionTest.java:103)
at com.kss.immg.tec.ProdInfoActionTest.main(ProdInfoActionTest.java:22)
Anyway, Thanks for your reply.
Exception in thread "main" java.lang.ClassCastException: org.codehaus.jettison.json.JSONArray
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:93)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:130)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeAttribute(MappedXMLStreamWriter.java:134)
at com.thoughtworks.xstream.io.xml.StaxWriter.addAttribute(StaxWriter.java:86)
at com.thoughtworks.xstream.io.WriterWrapper.addAttribute(WriterWrapper.java:30)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:43)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
at com.thoughtworks.xstream.converters.collections.MapConverter.marshal(MapConverter.java:46)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:44)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:46)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:112)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:88)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:117)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:73)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:73)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:765)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:754)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:735)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:725)
at com.kss.immg.tec.ProdInfoActionTest.testDetachedObjectWithSetPropertyToJson(ProdInfoActionTest.java:103)
at com.kss.immg.tec.ProdInfoActionTest.main(ProdInfoActionTest.java:22)
17 楼
JJYAO
2007-07-12
david3d 写道
The same question as above to JJYAO...
How to remove the reference of cglib?
Currently I encounter an issue while converting a hibernate set property to Json(I think XML should have same problem). Could u explain the solution to us?
Thank u very much in advance.
How to remove the reference of cglib?
Currently I encounter an issue while converting a hibernate set property to Json(I think XML should have same problem). Could u explain the solution to us?
Thank u very much in advance.
Version: xstream 1.2.1
To make comments on XStream.java from line 635 to 640, then re-compile
// if (jvm.loadClass("net.sf.cglib.proxy.Enhancer") != null) { // dynamicallyRegisterConverter( // "com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter", // PRIORITY_NORMAL, new Class[]{Mapper.class, ReflectionProvider.class}, // new Object[]{mapper, reflectionProvider}); // }
16 楼
wtusmchen
2007-07-12
支持xStream,一直用它!好使!!
15 楼
david3d
2007-07-11
The same question as above to JJYAO...
How to remove the reference of cglib?
Currently I encounter an issue while converting a hibernate set property to Json(I think XML should have same problem). Could u explain the solution to us?
Thank u very much in advance.
How to remove the reference of cglib?
Currently I encounter an issue while converting a hibernate set property to Json(I think XML should have same problem). Could u explain the solution to us?
Thank u very much in advance.
14 楼
teligen
2007-06-27
JJYAO,how to remove the reference of cglib?
13 楼
oksonic
2007-04-16
fire使用的却是xmlbean
12 楼
生命火花
2007-04-16
已经习惯了用JAXB了!各方面都还满意
11 楼
JAVA_ED
2007-04-16
JJYAO 写道
I find another compatible problem today.
In version 1.2
output:
<Form>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</Form>
In version 1.1
output:
<list>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</list>
So, i decide to give up using xstream in my next version project
Insured insured1 = new Insured(); insured1.setInsuredName("insured1"); Insured insured2 = new Insured(); insured2.setInsuredName("insured2"); List list = new ArrayList(); list.add(insured1); list.add(insured2); XStream xstream = new XStream(new DomDriver()); xstream.alias("Form", List.class); String xml = xstream.toXML(list); System.out.println(xml);
In version 1.2
output:
<Form>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</Form>
In version 1.1
output:
<list>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</list>
So, i decide to give up using xstream in my next version project
That's why you should realize inheriting from third-party util classes is really
important. I don't believe you should reject for the compatible issue.
10 楼
JJYAO
2007-04-13
I find another compatible problem today.
In version 1.2
output:
<Form>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</Form>
In version 1.1
output:
<list>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</list>
So, i decide to give up using xstream in my next version project
Insured insured1 = new Insured(); insured1.setInsuredName("insured1"); Insured insured2 = new Insured(); insured2.setInsuredName("insured2"); List list = new ArrayList(); list.add(insured1); list.add(insured2); XStream xstream = new XStream(new DomDriver()); xstream.alias("Form", List.class); String xml = xstream.toXML(list); System.out.println(xml);
In version 1.2
output:
<Form>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</Form>
In version 1.1
output:
<list>
<sojo.sample.Insured>
<insuredName>insured1</insuredName>
</sojo.sample.Insured>
<sojo.sample.Insured>
<insuredName>insured2</insuredName>
</sojo.sample.Insured>
</list>
So, i decide to give up using xstream in my next version project
9 楼
JJYAO
2007-03-30
lordhong 写道
JJYAO 写道
I don't like xstream very much. There are lots of backwards compatibility problems when you upgrade ver1.1 to ver1.2. So, xstream is not a good choice for using widely.
you are funny... we pick the latest version 1.2, no problem at all.
backward incompatible should not be the reason why we should not use xstream...
e.g
ver1.1 Class CollectionConverter(ClassMapper classMapper, java.lang.String classAttributeIdentifier) ver1.2 Class CollectionConverter(Mapper mapper) ver1.1 Interface ClassMapper.lookupName(java.lang.Class type) ver1.2 Don't have this method ver1.1 Interface HierarchicalStreamWriter void addAttribute(java.lang.String name, java.lang.String value) void endNode() void setValue(java.lang.String text) void startNode(java.lang.String name) ver1.2 Interface HierarchicalStreamWriter void addAttribute(java.lang.String name, java.lang.String value) void close() void endNode() void flush() void setValue(java.lang.String text) void startNode(java.lang.String name) HierarchicalStreamWriter underlyingWriter()
You can find there are many differences between ver1.1 and ver1.2
and another serious problem that if your objects are loaded via hibernate and
proxied by Cglib, an error will happen. but it runs well in ver1.1.
Because ver1.2 uses cglib to enhance the process of serialization, but it has
some limits.
It is ok after i remove the reference of cglib from ver1.2
8 楼
roc8633284
2007-03-30
fins 写道
xstream + xpp 的组合绝对够出色
速度快 效率高(似乎是一个意思 哈哈)
xpp3 最新版本是 xpp3-1.1.4c
XML Pull Parser是一种高速的 解析xml文件的方式
速度要比传统方式快很多(但是功能弱了些)
感兴趣的可以去google一下 "xpp"
速度快 效率高(似乎是一个意思 哈哈)
xpp3 最新版本是 xpp3-1.1.4c
XML Pull Parser是一种高速的 解析xml文件的方式
速度要比传统方式快很多(但是功能弱了些)
感兴趣的可以去google一下 "xpp"
偶像说什么我都信____追星的我
7 楼
fins
2007-03-30
xstream + xpp 的组合绝对够出色
速度快 效率高(似乎是一个意思 哈哈)
xpp3 最新版本是 xpp3-1.1.4c
XML Pull Parser是一种高速的 解析xml文件的方式
速度要比传统方式快很多(但是功能弱了些)
感兴趣的可以去google一下 "xpp"
速度快 效率高(似乎是一个意思 哈哈)
xpp3 最新版本是 xpp3-1.1.4c
XML Pull Parser是一种高速的 解析xml文件的方式
速度要比传统方式快很多(但是功能弱了些)
感兴趣的可以去google一下 "xpp"
6 楼
lordhong
2007-03-30
JJYAO 写道
I don't like xstream very much. There are lots of backwards compatibility problems when you upgrade ver1.1 to ver1.2. So, xstream is not a good choice for using widely.
you are funny... we pick the latest version 1.2, no problem at all.
backward incompatible should not be the reason why we should not use xstream...
5 楼
JJYAO
2007-03-29
I don't like xstream very much. There are lots of backwards compatibility problems when you upgrade ver1.1 to ver1.2. So, xstream is not a good choice for using widely.
4 楼
moogle
2006-11-17
目前我发现就xtream最简单,不需要生成dtd,无用配置,不需要生成辅助类,虽然功能相对其他的同类工具要简单,但是已经可以满足我的要求了. 所以才采用这个的.
3 楼
together
2006-11-17
hibernate有第三方工具,可以方便的在xml/obj/db之间转换的。
2 楼
zgdhj95
2006-11-17
好像转换的效率比较低~~
1 楼
moogle
2006-11-16
第2个问题已经解决。
加入xpp3_min-1.1.3.4.O.jar(包含在xStream压缩包中)
将
修改为:
加入xpp3_min-1.1.3.4.O.jar(包含在xStream压缩包中)
将
XStream sm = new XStream(new DomDriver());
修改为:
XStream sm = new XStream();
发表评论
-
Hibernate 对象查询生成的SQL的疑问[已解决]
2007-04-17 19:59 4770惟一外键关键的情况(many-to-one):我用了二个这 ... -
请问Hibernate中Criteria Query可以使用原生sql作为排序条件么?
2007-01-10 12:01 4122正常情况下是 addOrder(Order.desc(&quo ... -
疑问:Spring配置Quartz例子出错,请看下.谢谢
2006-12-13 14:35 23971研究了一天,在官方论坛也查询了很多,就是锁定不了原因。请各位朋 ... -
配置Spring 支持 Web session,request
2006-12-11 23:13 7244费了1天劲,终于琢磨出来了。。。。 配置Spring使得支持S ... -
Hibernate 要点
2006-11-24 08:32 1686Hibernate 如果采用 ThreadLocal ... -
pager-taglib 的使用
2006-11-22 23:36 4464Pager-taglib 2.0 是一套分页标签库,可以灵 ... -
Confluence 无限制使用
2006-11-22 21:36 123一直很喜欢使用Confluence,可是它是商业软件,要收钱的 ... -
[转]UrlRewrite Filter
2006-11-22 21:17 1663一:首先在到官方站点下载最新的jar文件 http://tuc ... -
[转]Tomcat 5.0.28 连接池配置
2006-11-22 09:58 3004其实Tomcat的连接池配置并不是很难,但也花费了我一些时间。 ... -
[转]Tomcat类加载机制
2006-11-22 08:58 2037TOMCAT源码分析(启动框架 ... -
Log4j应用
2006-11-23 11:20 25091.Log4j初始化: 最简单的配置方式:将配置文件取名log ... -
JasperReport
2006-11-19 20:02 101在进行HTML,Excel, RTF格式,或者干脆直接打印到打 ... -
PTViewer 全景显示
2006-11-19 00:03 3313全景显示 http://www.fsoft.it/panora ... -
XStream使用学习
2006-11-18 17:46 6678java 代码 import java.io. ... -
全景展示 - ptviewer.jar
2006-11-17 00:04 83全景英文名为Panorama,又叫虚拟全景、全景虚拟现实等, ... -
开发和使用JSP自定义标签过程
2006-11-16 23:56 1850开发和使用JSP自定义标签过程: 1.开发标签实现类. H ... -
log4j的配置方法
2006-11-16 23:35 88平时都是使用了一个专门的servlet来初始化log4j,刚看 ...
相关推荐
总之,XStream提供了一种直观且易于使用的机制来处理Java对象与XML之间的转换。结合Android的文件操作,我们可以方便地将数据序列化后存储到外部存储中,以便于后续读取和使用。通过熟练掌握XStream,开发者可以更...
在Java开发中,数据序列...总之,XStream是一个强大且易于使用的工具,可以帮助开发者轻松地在XML和Java对象之间进行转换。通过理解其工作原理和提供的功能,我们可以更有效地在Java项目中利用XML进行数据存储和交换。
在`xmlAnalysis`文件夹中,可能包含了一个简单的Java程序,演示了如何使用DOM、SAX、StAX和XStream解析XML文件,并展示了XStream如何在JavaBean与XML之间进行转换。你可以运行这些代码,观察输出结果,以加深理解。...
总之,XStream是一个强大的工具,可以帮助开发者轻松地在XML和Java对象之间进行转换。通过自定义转换器,我们可以精确控制序列化和反序列化的过程,满足各种复杂需求。在实际开发中,熟练掌握XStream的使用,能够...
**XStream:JavaBean与XML/JSON之间的转换大师** XStream是一个开源库,它为Java对象提供了简单且直观的XML序列化和反序列化的解决方案。它不仅能够将Java对象转换成XML,反之亦然,还能支持JSON格式的转换。这个...
// 使用Jackson的XML解析库将XML转换为Java对象 ObjectMapper xmlMapper = new XmlMapper(); Person deserializedPerson = xmlMapper.readValue(xml, Person.class); // 使用Gson将Java对象转换为JSON Gson gson = ...
总的来说,XStream是一个功能丰富的库,它使得Java对象与XML之间的转换变得简单易行。通过理解和掌握XStream的用法,开发者可以更高效地处理数据序列化需求,无论是在存储、传输还是解析XML文档的场景下。
总的来说,xStream是Java开发中处理XML和JSON的强大工具,它提供了简单易用的API来实现对象与这两种数据格式之间的转换。通过理解和掌握xStream的使用,开发者可以更高效地处理数据序列化和反序列化任务。
标题 "xStream完美转换XML、JSON" 指的是使用xStream库在Java中进行XML与JSON数据格式之间的转换。xStream是一个强大的库,它提供了一种简单的方式来序列化和反序列化Java对象到XML,反之亦然。在这个场景中,它同样...
总之,XStream 提供了一个强大而灵活的工具,使得Java对象和XML之间的转换变得简单,适合在各种场景下使用。在实际开发中,根据项目的具体需求,合理配置XStream可以极大地提升代码的可维护性和可读性。
总的来说,这个“基于java的开发源码-转换xml.zip”可能包含了如何使用XStream进行XML和Java对象之间的转换的实际代码示例,对于学习或工作中处理XML数据的Java开发者来说,这是一个非常有价值的资源。通过深入理解...
它的核心功能是能够将任何Java对象转换为XML,然后再从XML转换回来,而无需编写大量的代码。这使得数据交换、持久化或者网络传输变得非常便捷。 **序列化过程** 1. **配置XStream实例**:首先,我们需要创建一个...
标题中的“XStream实现Object与XML转换解决方案”指的是一个Java库——XStream,它提供了一种简单的方法来序列化和反序列化Java对象到XML,反之亦然。这个库广泛用于将程序数据保存到XML文件或者从XML数据恢复对象,...
2. **对象到XML转换**:通过调用`toXML()`方法,我们可以将任何Java对象转换为XML字符串。这个过程会递归地处理对象的所有字段,除非它们被标记为忽略。 3. **XML到对象转换**:使用`fromXML()`方法,我们可以从XML...
XStream是一款强大的Java库,主要用于实现Java对象与XML文档之间的相互转换。本文将详细介绍XStream的基本用法、配置选项以及如何利用它来进行对象到XML的序列化和反序列化操作。 #### 一、XStream简介 XStream是...
总结,XStream是一个强大且易于使用的库,能够简化Java对象与XML之间的转换。通过了解其基本用法和自定义功能,开发者可以在项目中有效地利用XML进行数据交换和存储。在实际应用中,根据项目需求进行适当的配置和...
本主题涉及三个关键库:XStream 1.4.2,XMLPull 1.1.3.1和XPP3_min 1.1.4c,它们在对象到XML转换中扮演着重要角色。 **XStream 1.4.2** 是一个强大的Java库,它能够将Java对象序列化为XML,并从XML反序列化回Java...
它们可能会创建一些包含Date对象的Java类,然后使用XStream实例进行序列化和反序列化操作,确保日期的转换符合预期。测试代码可能如下所示: ```java import com.thoughtworks.xstream.XStream; import ...
通过这个示例,我们可以了解到XStream如何简化Java对象与XML之间的转换,以及如何自定义转换规则以满足特定需求。无论是进行数据持久化,还是进行网络数据交换,XStream都是一个非常实用的工具。在深入研究源码时,...