{"id":2962,"date":"2018-08-06T19:37:34","date_gmt":"2018-08-06T11:37:34","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2962"},"modified":"2018-08-06T19:37:34","modified_gmt":"2018-08-06T11:37:34","slug":"xsteam-%e5%8e%bb%e6%8e%89-class-%e5%b1%9e%e6%80%a7%e5%92%8c%e8%bf%87%e6%bb%a4%e5%8f%8c%e4%b8%8b%e5%88%92%e7%ba%bf%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2962","title":{"rendered":"XSteam \u53bb\u6389 class \u5c5e\u6027\u548c\u8fc7\u6ee4\u53cc\u4e0b\u5212\u7ebf\u95ee\u9898"},"content":{"rendered":"<p>\n\t\u5927\u7ea6\u5728 2 \u5e74\u4ee5\u524d\uff0c\u6211\u4eec\u505a\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u901a\u8baf\uff0c\u62a5\u6587\u7528\u7684\u662f xml \u683c\u5f0f\u7684\u3002\u5728 xml \u548c\u5b9e\u4f53\u7c7b\u4e4b\u95f4\u6211\u4eec\u4f7f\u7528\u4e86 XStream \u6765\u89e3\u6790 xml \u548c\u81ea\u52a8\u5c06 xml \u8f6c\u5316\u6210 bean \u7684\u6846\u67b6\u3002\u4eca\u5929\u5728\u5bf9\u63a5\u987a\u4e30\u5feb\u9012\u65f6\u53c8\u7528\u5230\u6765 xml \u62a5\u6587\u3002\u987a\u4e30\u5f53\u524d\u8fd8\u4e0d\u652f\u6301 json \u683c\u5f0f\u7684\u62a5\u6587\uff0c\u6240\u4ee5\u6211\u4eec\u6ca1\u5f97\u9009\u62e9\uff0c\u5fc5\u987b\u4f7f\u7528 xml \u7684\u89e3\u6790\u548c\u751f\u6210\u3002\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u6765\u4e00\u4e9b\u95ee\u9898\uff0c\u6211\u8fd9\u91cc\u603b\u7ed3\u4e00\u4e0b\uff01\n<\/p>\n<p>\n\t\u7b2c\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\uff0c\u5b9e\u4f53\u7c7b\u5bf9\u8c61\u751f\u6210 xml \u5b57\u7b26\u4e32\u65f6\uff0c\u5b9e\u4f53\u7c7b\u5bf9\u8c61\u8282\u70b9\u81ea\u52a8\u5e26\u6709\u4e00\u4e2a class \u5c5e\u6027\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u53bb\u6389\u8fd9\u4e2a class \u5c5e\u6027\u5462\uff1f\n<\/p>\n<p>\n\t\u5177\u4f53 xml \u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n&lt;xttblog class=&quot;com.xttblog.siteinfo&quot;&gt;\r\n      &lt;sitename&gt;\u4e1a\u4f59\u8349&lt;\/fieldChName&gt;\r\n      &lt;url&gt;www.xttblog.com&lt;\/fieldEnName&gt;\r\n      &lt;mp_weixin&gt;\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349&lt;\/fieldContent&gt;\r\n&lt;\/fieldInfo&gt;<\/pre>\n<p>\n\t\u6211\u4eec\u91c7\u7528\u7684 XStream \u7684\u7248\u672c\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;dependency&gt;\r\n            &lt;groupId&gt;com.thoughtworks.xstream&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;xstream&lt;\/artifactId&gt;\r\n            &lt;version&gt;1.4.10&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>\n\t\u89e3\u51b3\u529e\u6cd5\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u8bbe\u7f6e XStream \u7684&nbsp;aliasSystemAttribute \u5c5e\u6027\u5373\u53ef\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e8c\u4e2a\u95ee\u9898\u5462\uff0c\u5c31\u662f\u5e26\u6709\u4e0b\u5212\u7ebf\u7684\u8282\u70b9\uff0c\u5728\u751f\u6210 xml \u540e\uff0c\u4e0b\u5212\u7ebf\u90fd\u53d8\u6210\u4e24\u4e2a\u4e86\u3002\u5177\u4f53\u5982\u4e0b\u6240\u793a\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;xttblog class=&quot;com.xttblog.siteinfo&quot;&gt;\r\n      &lt;sitename&gt;\u4e1a\u4f59\u8349&lt;\/fieldChName&gt;\r\n      &lt;url&gt;www.xttblog.com&lt;\/fieldEnName&gt;\r\n      &lt;mp__weixin&gt;\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349&lt;\/fieldContent&gt;\r\n&lt;\/fieldInfo&gt;<\/pre>\n<p>\n\t\u89e3\u51b3\u529e\u6cd5\u5c31\u662f\u8bbe\u7f6e XmlFriendlyNameCoder \u7684\u7f16\u89e3\u7801\u65b9\u5f0f\u3002\u8be6\u7ec6\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\nXStream xStream = new XStream(new DomDriver(&quot;UTF-8&quot;, new XmlFriendlyNameCoder(&quot;-_&quot;, &quot;_&quot;)));<\/pre>\n<p>\n\t\u5176\u5b9e XStream \u91cc\u9762\u8fd8\u6709\u5f88\u591a\u5176\u4ed6\u7684\u5751\uff0c\u6211\u4eec\u4ee5\u540e\u9047\u5230\u518d\u8bf4\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2962\">XSteam \u53bb\u6389 class \u5c5e\u6027\u548c\u8fc7\u6ee4\u53cc\u4e0b\u5212\u7ebf\u95ee\u9898<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5927\u7ea6\u5728 2 \u5e74\u4ee5\u524d\uff0c\u6211\u4eec\u505a\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u901a\u8baf\uff0c\u62a5\u6587\u7528\u7684\u662f xml \u683c\u5f0f\u7684\u3002\u5728 xml \u548c\u5b9e\u4f53\u7c7b\u4e4b\u95f4\u6211\u4eec\u4f7f\u7528\u4e86  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[364,553,270,365,367],"class_list":["post-2962","post","type-post","status-publish","format-standard","hentry","category-java","tag-javaxml","tag-spring-xml","tag-web-xml","tag-xstream"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2962"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2962\/revisions"}],"predecessor-version":[{"id":2963,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2962\/revisions\/2963"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}