你们好,我用weixin java tools报Cannot create XmlPullParser异常,请高手们怎么解决

Damian_Yu 发布于 2015/06/02 10:34
阅读 1K+
收藏 0
加载中
0
耀
耀点
我也遇到这个问题
0
My-橘子
My-橘子
改XStreamInitializer类就可以了:
public class XStreamInitializer {

	public static XStream getInstance() {
		// XStream xstream = new XStream(new XppDriver() {
		//
		// @Override
		// public HierarchicalStreamWriter createWriter(Writer out) {
		// return new PrettyPrintWriter(out, getNameCoder()) {
		// protected String PREFIX_CDATA = "<![CDATA[";
		// protected String SUFFIX_CDATA = "]]>";
		// protected String PREFIX_MEDIA_ID = "<MediaId>";
		// protected String SUFFIX_MEDIA_ID = "</MediaId>";
		// @Override
		// protected void writeText(QuickWriter writer, String text) {
		// if (text.startsWith(PREFIX_CDATA) && text.endsWith(SUFFIX_CDATA)) {
		// writer.write(text);
		// } else if (text.startsWith(PREFIX_MEDIA_ID) &&
		// text.endsWith(SUFFIX_MEDIA_ID)) {
		// writer.write(text);
		// } else {
		// super.writeText(writer, text);
		// }
		//
		// }
		// };
		// }
		// });
		// xstream.ignoreUnknownElements();
		// xstream.setMode(XStream.NO_REFERENCES);
		// xstream.addPermission(NullPermission.NULL);
		// xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
		// return xstream;
		XStream xstream = new XStream(new DomDriver() {
			@Override
			public HierarchicalStreamWriter createWriter(Writer out) {
				return new PrettyPrintWriter(out, getNameCoder()) {
					protected String PREFIX_CDATA = "<![CDATA[";
					protected String SUFFIX_CDATA = "]]>";
					protected String PREFIX_MEDIA_ID = "<MediaId>";
					protected String SUFFIX_MEDIA_ID = "</MediaId>";

					@Override
					protected void writeText(QuickWriter writer, String text) {
						if (text.startsWith(PREFIX_CDATA)
								&& text.endsWith(SUFFIX_CDATA)) {
							writer.write(text);
						} else if (text.startsWith(PREFIX_MEDIA_ID)
								&& text.endsWith(SUFFIX_MEDIA_ID)) {
							writer.write(text);
						} else {
							super.writeText(writer, text);
						}

					}
				};
			}
		});
		xstream.ignoreUnknownElements();
		xstream.setMode(XStream.NO_REFERENCES);
		xstream.addPermission(NullPermission.NULL);
		xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
		return xstream;
	}

}



lailaiping
lailaiping
确实如此 不知道什么原因
返回顶部
顶部