问题描述
- xstream将xml解析为bean,出差,急急急
-
这是我定义的两个用来接收的beanpublic 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