2013-02-25 72 views
2

我有一個TomCat服務器運行幾個webapps。如何將XML文件上傳到TomCat?

我想將一個XML文件上傳到我的TomCat服務器上,這樣我就可以用我在C#中開發的程序訪問和下載該文件。

我已經做了很多搜索,並且沒有可靠的線索,那麼如何將文件上傳到Tomcat服務器以便可以訪問?

For example, I want my program to be able to use this: 
get file from(http://tomcat-ip:port/example/data.xml) 

謝謝。


想出解決辦法:將在的webapps /根的文件,你將能夠訪問來自主機的文件:端口/文件名


+0

想出解決辦法:將在的webapps /根的文件,你將能夠從主機訪問文件:端口/文件名 – user2019260 2013-02-25 22:35:39

回答

1

如果您運行的tomact服務器在XAMPP你可以把你xml文件C:\xampp\htdocs 代碼:

URL oracle = new URL("http://localhost/data.xml); 
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream())); 

while ((inputLine = in.readLine()) != null) 
{ 
    Sysetm.out.println(inputLine); 
} 
in.close(); 

如果你甲肝ËHTML表格也可以進行數組:

Document doc = Jsoup.parse(inputLine); 
      Elements tables = doc.select("table"); 
      for (Element table : tables) { 
       Elements trs = table.select("tr"); 
       String[][] trtd = new String[trs.size()][]; 
       for (int i = 0; i < trs.size(); i++) { 
        Elements tds = trs.get(i).select("td"); 
        trtd[i] = new String[tds.size()]; 
        for (int j = 0; j < tds.size(); j++) { 
         trtd[i][j] = tds.get(j).text(); 
        } 
       } 
       // trtd now contains the desired array for this table 
        System.out.println(trtd[column][row]); 
      } 
+0

如果你正在你需要數組Jsoup庫 – 2013-02-25 20:39:53

+0

如果你在eclipse中有tomcat服務器,那麼用data.xml在 – 2013-02-25 20:41:17

+0

內建立一個項目對不起......我有點困惑。如果我想簡單地將文件上傳到我的Tomcat服務器(從服務器計算機本身),我是否需要代碼? 我的想法是,我只需要將文件放在適當的位置,也許可以改變一些配置? 謝謝 – user2019260 2013-02-25 20:41:45