xstream解析问题-xstream将xml解析为bean,出差,急急急

问题描述

xstream将xml解析为bean,出差,急急急

这是我定义的两个用来接收的bean

 public class BulletinResponse {

    private String transId;

    private String processTime;

    private String cpId;

    private String curPage;

    private String pageCount;

    private String returnCode;

    private String content;
    private List<Info> infoList;

    public String getTransId() {
        return transId;
    }

    public void setTransId(String transId) {
        this.transId = transId;
    }

    public String getProcessTime() {
        return processTime;
    }

    public void setProcessTime(String processTime) {
        this.processTime = processTime;
    }

    public String getCpId() {
        return cpId;
    }

    public void setCpId(String cpId) {
        this.cpId = cpId;
    }

    public String getCurPage() {
        return curPage;
    }

    public void setCurPage(String curPage) {
        this.curPage = curPage;
    }

    public String getPageCount() {
        return pageCount;
    }

    public void setPageCount(String pageCount) {
        this.pageCount = pageCount;
    }

    public String getReturnCode() {
        return returnCode;
    }

    public void setReturnCode(String returnCode) {
        this.returnCode = returnCode;
    }

    public List<Info> getInfoList() {
        return infoList;
    }

    public void setInfoList(List<Info> infoList) {
        this.infoList = infoList;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

}
 public class Info {

    private String contentCode;

    private String gameName;

    private String osVersion;

    private String monthlyType;

    private String lastupdate;

    private String status;

    private String sourceType;

    private String approveStatus;

    public String getGameName() {
        return gameName;
    }

    public void setGameName(String gameName) {
        this.gameName = gameName;
    }

    public String getOsVersion() {
        return osVersion;
    }

    public void setOsVersion(String osVersion) {
        this.osVersion = osVersion;
    }

    public String getMonthlyType() {
        return monthlyType;
    }

    public void setMonthlyType(String monthlyType) {
        this.monthlyType = monthlyType;
    }

    public String getLastupdate() {
        return lastupdate;
    }

    public void setLastupdate(String lastupdate) {
        this.lastupdate = lastupdate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getSourceType() {
        return sourceType;
    }

    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }

    public String getApproveStatus() {
        return approveStatus;
    }

    public void setApproveStatus(String approveStatus) {
        this.approveStatus = approveStatus;
    }

    public String getContentCode() {
        return contentCode;
    }

    public void setContentCode(String contentCode) {
        this.contentCode = contentCode;
    }

}

这是返回的xml

 <?xml version="1.0" encoding="UTF-8"?>
<notifyRsp>
     <transId>1447296864744</transId>
     <processTime>20151112105424</processTime>
     <cpId>710791</cpId>
     <curPage>1</curPage>
     <pageCount>181</pageCount>
     <returnCode>0000</returnCode>
         <content>
             <contentCode>006011863000</contentCode>
             <gameName>安卓单机112_001</gameName>
             <monthlyType></monthlyType>
             <osVersion>1</osVersion>
             <status>8</status>
             <sourceType>2</sourceType>
             <approveStatus>1,3|2,3|3,3|4,3|5,3|6,3|7,3|8,3</approveStatus>
             <lastupdate>Nov 12, 2015 10:40:54 AM</lastupdate>
         </content>
         <content>
             <contentCode>006011767000</contentCode>
             <gameName>20151110yxshi单机_android</gameName>
             <monthlyType></monthlyType>
             <osVersion>1</osVersion>
             <status>8</status>
             <sourceType>2</sourceType>
             <approveStatus>1,3|2,1|3,1|4,1|5,1|6,1|7,2|8,3</approveStatus>
             <lastupdate>Nov 10, 2015 3:06:43 PM</lastupdate>
         </content>
         <content>
             <contentCode>006011769000</contentCode>
             <gameName>20151110yxshi网游IOS</gameName>
             <monthlyType></monthlyType>
             <osVersion>2</osVersion>
             <status>8</status>
             <sourceType>2</sourceType>
             <approveStatus>1,3|2,1|3,1|4,1|5,1|6,1|7,1|8,3|9,1</approveStatus>
             <lastupdate>Nov 10, 2015 3:06:08 PM</lastupdate>
         </content>
         <content>
             <contentCode>006011768000</contentCode>
             <gameName></gameName>
             <monthlyType></monthlyType>
             <osVersion>1</osVersion>
             <status>0</status>
             <sourceType>2</sourceType>
             <approveStatus></approveStatus>
             <lastupdate>Nov 10, 2015 2:54:20 PM</lastupdate>
         </content>
         <content>
             <contentCode>006011765000</contentCode>
             <gameName></gameName>
             <monthlyType></monthlyType>
             <osVersion>1</osVersion>
             <status>0</status>
             <sourceType>2</sourceType>
             <approveStatus></approveStatus>
             <lastupdate>Nov 10, 2015 2:19:00 PM</lastupdate>
         </content>
</notifyRsp>

这是解析xml的方法就在这里一直报错

 XStream xStream = new XStream(new DomDriver("utf-8"));
 BulletinResponse bean = (BulletinResponse) xStream.fromXML(responseStr);
xStream.addImplicitCollection(BulletinResponse.class, "infoList");

错误信息

 Exception in thread "main" com.thoughtworks.xstream.mapper.CannotResolveClassException: notifyRsp : notifyRsp
    at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:52)
    at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:845)
    at cn.emag.business.announInfo.service.Test.parseResponseStr(Test.java:55)
    at cn.emag.business.announInfo.service.Test.main(Test.java:43)

解决方案

Unterminated <%@ page tag 急急急!!!!
求助,急急急!!!

时间: 2024-10-02 19:58:01

xstream解析问题-xstream将xml解析为bean,出差,急急急的相关文章

iOS开发之网络数据解析(二)--XML解析简介

前言:本篇随笔介绍的是XML解析.   正文:   1.XML解析方式有2两种: DOM:一次性将整个XML数据加载进内存进行解析,比较适合解析小文件 SAX:从根元素开始,按顺序一个元素一个元素往下解析,比较适合解析大文件   2.IOS中XML解析方案有很多种: 2-1.第三方框架: libxml2:纯C语言,默认包含在iOS SDK中,同时支持DOM和SAX解析 GDataXML:DOM方式解析,由Google开发,基于libxml2 2-2.苹果原生 NSXMLParser:SAX方式解

XML入门教程:XML 解析器

xml|教程|入门教程 如需读取.更新.创建或者操作某个XML文档,则需要XML解析器. 实例 解析XML文件 - 跨浏览器的实例 本例是一个跨浏览器的实例,把某个XML文档("note.xml")载入XML解析器. <html><body><script type="text/vbscript">set xmlDoc=CreateObject("Microsoft.XMLDOM")xmlDoc.async=&

微软xml解析器

XML解析器可以读取.更新.创建.操作一个XML文档. -------------------------------------------------------------------------------- 使用XML解析器 微软的XML解析器是和IE5.0+浏览器捆绑在一起的. 一旦你安装了IE5.0,那么就获得了XML解析器.这个浏览器除了被浏览器内部调用外,还可以在脚本中或者程序中调用.这个解析器的特点是支持与程序设计语言无关的编程模型,他支持以下技术: JavaScript,

XML指南——微软的XML解析器

    XML解析器可以读取.更新.创建.操作一个XML文档.使用XML解析器微软的XML解析器是和IE5.0+浏览器捆绑在一起的.一旦你安装了IE5.0,那么就获得了XML解析器.这个浏览器除了被浏览器内部调用外,还可以在脚本中或者程序中调用.这个解析器的特点是支持与程序设计语言无关的编程模型,他支持以下技术:JavaScript, VBScript, Perl, VB, Java, C++ 等等 W3C XML 1.0 和 XML DOM DTD 和 XML文档验证 如果浏览器使用JavaS

xstream解析问题-xstream将返回的xml解析为bean,出错,急急急

问题描述 xstream将返回的xml解析为bean,出错,急急急 public class BulletinResponse { private String transId; private String processTime; private String cpId; private String curPage; private String pageCount; private String returnCode; private String content; private Li

android XMl 解析神奇xstream 四: 将复杂的xml文件解析为对象

前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xstream 二: 把对象转换成xml android XMl 解析神奇xstream 三: 把复杂对象转换成 xml   1.文件准备 把一个预先写好的xml文件放在android项目目录的 asset 文件夹. 文件内容为: <blog> <age>30</age> &l

android XMl 解析神奇xstream 五: 把复杂对象转换成 xml ,并写入SD卡中的xml文件

前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xstream 二: 把对象转换成xml android XMl 解析神奇xstream 三: 把复杂对象转换成 xml android XMl 解析神奇xstream 四: 将复杂的xml文件解析为对象   1.建立JavaBeen package com.android10; public clas

android XMl 解析神奇xstream 二: 把对象转换成xml

前言:对xstream不理解的请看:android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件   1.Javabeen 代码 package com.android10; public class Product { private String name ; private String age ; public String getName() { return name; } public void setName(Str

从任意数据结构生成XML解析器产生SAX事件

xml|生成xml|数据|数据结构  在j2ee1.4标准教材里看到一个很有趣的例子,从任意数据结构生成XML解析器产生SAX事件.数据结构可以是文本文件,PDF格式文档等.关键是自己解析这些数据源.另外一个有意思的地方是观察者模式的应用.所以就粗糙的改了一下并完整到可以测试运行.观察者模式简略UML图: 具体实现 被观察者对象ParseXMLSubject类:package test; import java.io.*;import org.xml.sax.helpers.Attributes