{"id":85915,"date":"2020-05-15T04:15:33","date_gmt":"2020-05-14T20:15:33","guid":{"rendered":"http:\/\/4563.org\/?p=85915"},"modified":"2020-05-15T04:15:33","modified_gmt":"2020-05-14T20:15:33","slug":"%e5%85%b3%e4%ba%8e-listt%e4%b8%ad-t-%e6%83%b3%e6%94%b9%e6%88%90%e5%8f%98%e9%87%8f%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85915","title":{"rendered":"\u5173\u4e8e List&lt;T&gt;\u4e2d T \u60f3\u6539\u6210\u53d8\u91cf\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e List&lt;T&gt;\u4e2d T \u60f3\u6539\u6210\u53d8\u91cf\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SupperHobby <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u6709\u8fd9\u4e48\u4e00\u4e2a\u65b9\u6cd5<\/p>\n<pre><code>public String importDataUnion(Class&lt;? extends BaseEntity&gt; clazz , MultipartFile file ) {     ExcelUtil&lt;T&gt; util = new ExcelUtil&lt;&gt;(T.class);     List&lt;T&gt; listExcel = util.importExcel(file.getInputStream());     return import(listExcel); } <\/code><\/pre>\n<p>\u6211\u60f3\u7ed9 ExcelUtil \u548c List \u7684 T \u4f20\u4e00\u4e2a\u4e0d\u786e\u5b9a\u7684\u5b9e\u4f53\u7c7b clazz\uff0c\u56e0\u4e3a\u6211\u6709\u5f88\u591a\u5b9e\u4f53\u7c7b\u7c7b\uff0c\u4f1a\u91cd\u590d\u8fd9\u6bb5\u4ee3\u7801\uff0c\u4f46\u662f\u7ed9\u7c7b\u578b\u4f20\u53d8\u91cf\u4f1a\u62a5\u9519\uff0c\u4e0d\u77e5\u9053\u8be5\u600e\u4e48\u5904\u7406\u4e86 QAQ\uff0chelp!~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1503018\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lancelock <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             .getClass() \u65b9\u6cd5\u8fd4\u56de\u5b9e\u4f8b\u7684\u7c7b\u578b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1503019\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : SupperHobby <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lancelock \u4e0d\u884c\u8bf6 \u8fd9\u6837\u5199 List&lt;clazz.getClass()&gt; \u4f1a\u62a5\u9519 cannot resolve symbol &#8216;getClass&#8217; \u56e0\u4e3a clazz \u662f\u4e2a\u53d8\u91cf\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1503020\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pursuer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             public &lt;T extends BaseEntity&gt; String importDataUnion(Class&lt;T&gt; clazz, MultipartFile file){<br \/> ExcelUtil&lt;T&gt; util = new ExcelUtil&lt;&gt;(clazz);<br \/>&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1503021\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             3 \u6b63\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e List&lt;T&gt;\u4e2d&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85915"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85915"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85915\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85915"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}