2013-02-25 79 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