简体   繁体   English

使用Ajax,jQuery,Java读写文本文件

[英]Read and write text files using Ajax, jQuery, Java

I have a requirement to read and write bulk of text files at server side. 我需要在服务器端读写大量文本文件。

How can we write using Ajax, Java... Have little bit idea about these technologies but I just need an idea to implement. 我们如何使用Ajax,Java进行编写...对这些技术的了解很少,但我只需要实现一个想法即可。 After that I feel I can proceed. 之后,我觉得我可以继续。 Could you please help me? 请你帮助我好吗?

Firstly the text files are going to have to be publicly accessible. 首先,文本文件必须是可公开访问的。 They cannot exist in a private context on the server, as JavaScript is a client side technology. 它们不能存在于服务器的私有上下文中,因为JavaScript是一种客户端技术。

Once they are public, you can simply do an AJAX request on the file location, and then parse them as required. 它们公开后,您只需在文件位置发出AJAX请求,然后根据需要解析它们。

If having them in a public location is going to be a problem, you will need to have a page that serves them to authenticated accounts only, so only people that are logged in can view them. 如果将它们放在公共场所将是一个问题,则需要有一个仅将它们提供给经过身份验证的帐户的页面,因此只有登录的用户才能查看它们。 This means they will have to be served via a server side script at some point, which the AJAX request can then fetch as required. 这意味着它们将必须在某个时候通过服务器端脚本提供服务,然后可以根据需要获取AJAX请求。

However if you take this approach, you might as well take out the AJAX and just have the server side script do the processing for you and feed out the result. 但是,如果您采用这种方法,则最好删除AJAX,只让服务器端脚本为您进行处理并提供结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM