简体   繁体   English

从非形式部分检索Servlet信息

[英]Retrieving Servlet info from non-form parts

I am trying to create an application that reads JSON strings. 我正在尝试创建一个读取JSON字符串的应用程序。

Right now: I can input a JSON string through Java, write it to an HTML document and have a JavaScript application read it; 现在:我可以通过Java输入JSON字符串,将其写入HTML文档,然后让JavaScript应用程序读取它; which then parses it and writes it to the same HTML application. 然后解析它并将其写入相同的HTML应用程序。 I need to know how, using Java, to read the HTML that it gets written to so I can use that data. 我需要知道如何使用Java读取它写入的HTML,以便可以使用该数据。 It is important to note this HTML file is all generated by code so there is no actual text file to read. 请务必注意,此HTML文件都是由代码生成的,因此没有实际的文本文件可供读取。

I realize this is a roundabout way of doing it, but up until this point it has worked. 我意识到这是一种绕行的方式,但是直到现在为止它仍然有效。 My question is simple: How can I read an HTML page in a part that is not in a <form> through either regular Java or Servlet. 我的问题很简单:如何通过常规Java或Servlet读取<form>的部分中的HTML页面。

You can do that only by parsing the HTML in Java. 您只能通过用Java解析HTML来做到这一点。 And, there are some open source libraries that does this job for you. 而且,有一些开源库可以为您完成这项工作。

Here is one that you can use. 这是您可以使用的一种。 http://jsoup.org/ http://jsoup.org/

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

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