Xstream: Invalid byte 2 of 2-byte UTF-8 sequence.
Blog type:
Exception
Javaxml
Blog migration to: http://www.micmiu.com
When xstream is used to convert XML
An error is reported when deserialization is set to JavaBean. The information is as follows:
com.thoughtworks.xstream.io.StreamException: : Invalid byte 2 of 2-byte UTF-8 sequence. at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver
These two things are inherently different, JAXB is called the OX binding tool, XStream should be counted as a serialization tool, but the OX binding tool will also Marshall and Unmarshall , so this part of serialization is included. The serialization tool does not necessarily need to provide binding functionality. Now that you're all playing with serialization, simply compare the two of them in terms of serialization. JAXB: Toplink jaxb 10133, which s
The role of XStream XStream can convert JavaBean objects into xml! The data that the server responds to the client is usually a set of objects from the database, and we cannot directly respond to the object to the response, so we need to convert the object to XML and then respond to the client, then we need to use the XStream combination. 2
Sometimes in project development to transfer the XM file, to convert to string transmission, but not the use of object transfer, so to convert, used to summarize the use of XStream for string and XML objects, and in the conversion of a package of all the classes.
XML file parsing and creation, please refer to: http://blog.csdn.net/oyyz111/article/details/22730983
First, use spring's pathmatchingresourcepatternresolver to read a class file under a pack
XStream is a simple and practical Java class Library that is used to convert between a serialized object and an XML object. Because the XStream configuration is simple and flexible to use, there is a lot of space in the XML object and the Java object serialization market. This article does not elaborate on the features of XStream, but shows how easy it is to demo
In the serialization process of XML and common pojo, there are many methods. The xstream package is still good, and its author is written by the famous thoughtworks. The following is a simple analysis.
1 first is a pojo object, such:Public class employee {Private string name;Private string designation;Private string department;..........
2. Change pojo to an XML object.Xstream = new xstream (New domdriver
Package com.wanhua.util;Import Com.thoughtworks.xstream.XStream;Import Com.thoughtworks.xstream.io.xml.DomDriver;/*** Using XStream to convert entity classes to XML** @author W_xfpenga** 2014-11-27*/public class Xstream2text {static XStream XStream = new XStream (new Domdriver ());/*** Convert JavaBean objects to XML**
This article records some code examples that use the annotations feature of the XStream API to convert Java objects to and from XML strings.Many of us have worked with XML files, and there are many very mature third-party open source software. such as:Jdom,dom4j and so on. Although they are very powerful, they are still a bit less accustomed to use. For a fixed-format XML document, its structure does not change or change very little, then it is conve
A. Brief introduction:XStream can easily convert Java objects into XML, JSON. This blog will use SPRINGMVC integration to transform XML using XStream.Blog posts about XStream use: http://blog.csdn.net/zdp072/article/details/39054197Two. Example:1. Code structure diagram:2. Entity classes:(1) Accountpublic class Account { private int id; private String name; private String Email; Private String address; Private Birthday Birthday; Gett
I. Introduction:XStream can easily convert Java objects to XML, JSON. This blog will use SPRINGMVC integration to transform XML using XStream.Blog posts about XStream use: http://blog.csdn.net/zdp072/article/details/39054197Two. Example:1. Code structure diagram:2. Entity classes:(1) Accountpublic class Account { private int id; private String name; private String Email; Private String address; Private Birthday Birthday; Getter and s
Recently, in the process of doing the project, we used the XStream technology to realize the conversion between JavaBean and XML.
Do not say nonsense, for XStream learning, in the official website to step by step study, you can learn, but there are some problems will be encountered in the course of practice.
such as Chinese characters garbled problem.
Workaround:
File file= New file ("F://back.xml");InputSt
The following is an example of a javabean using XStream to convert XML data into multiple object combinations:
XML Message Format:
......
The following are the relevant Java classes for the corresponding XML:public class Suborderinfo {Private String orderid;//Payment order numberPrivate String amount;//Order AmountPrivate String installmenttimes;//Installment period 1, 3, 6, 9, 12, 18, 24;1 on behalf of full paymentPrivate String meracct;//merchant a
The XStream object is quite a translator between Java objects and XML, and the conversion process is bidirectional. The way to create a Xsteam object is simple, you just need a new XStream ().Java to XML, using the ToXml () method.XML to Java, using the FromXml () method.
In the absence of any default configuration, the Java to XML mapping is the Java member name corresponding to the XML element name, the
XStream bugs, such as the underscore "_" in the definition alias, will become "__" after being converted to XMLLike what:XStream stream=new XStream (); Stream.alias ("person", person.class); String Message=stream.toxml (person);If there is a field in the person class Per_name has _ converted to XML, it will appear __ How does this need to be solved?XStream
1. Create the queryorders. Java file:
/** * */package com.saicfc.pmpf.resume.bocom.utils.resume;import java.util.List;import com.thoughtworks.xstream.annotations.XStreamAlias;import com.thoughtworks.xstream.annotations.XStreamImplicit;/** * @author lizhiyong * */@XStreamAlias("BOCOMB2C")public class QueryOrders { public OpRep opRep; public OpRep getOpRep() { return opRep; } public class OpRep{ public String retCode; public String errMsg;
and Setter... ...}Note the difference in this object (how the property imagetypes is handled) Public class MetaData { @XStreamAlias("BATCH")PrivateBatch Batchnode;@XStreamAlias("Image_types")PrivateListNewArraylist@XStreamAlias("Count_per_page")PrivateString Countperpage;///Note that a solution that is converted to an XML node nesting after a duplicate naming //The node (image_types) is treated as a collection object Public void Add(String ImageType) { This. Imagetypes.add (ImageType
Note: XStream in the toxml for null values do not label output, the following converter modified this content.
There are examples of usage in the main method.
Import Java.lang.reflect.Method; Import java.util.ArrayList;Import Java.util.HashMap;Import java.util.List;Import Java.util.Map;Import Tellhow.ner.vo.BrakeVo;Import Tellhow.ner.vo.TransferComponentVo;Import Tellhow.ner.vo.Unit;Import Com.thoughtworks.xstream.XStream;Import Com.thoughtworks.xst
E-xstream Digimat v6.0.1 Win64 1DVD composite structural optimization simulation softwareE-xstream DIGIMAT-Nonlinear composite structural simulation software with examples and third-party components.Digimat is designed for rapid and highly accurate prediction of nonlinear behavior of multicomponent materials such as plastics, polymers, carbon and glass fibers, nanomaterials, etc., for multicomponent structu
Preface: For XStream do not understand, please see:Android XMl parsing Magic XStream: Parse aa.xml file under Asset folder in Android projectAndroid XML parsing Magic XStream II: Converting objects to XML1, Javabeen PackageCom.android10; Public classPerson {String pName; String PAge; PublicString Getpname () {returnPName; } Public voidsetpname (String
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.