简体   繁体   English

如何在JSP中检索内容/文件?

[英]How to retrieve the content/file in JSP?

I have a question about the JSP. 我对JSP有疑问。 I have a JSON file in the server and the content is like the following: 我的服务器中有一个JSON文件,内容如下:

{ "class":
    {
        "number": 2,
        "student": 
        {
        "name": "Tom",
        "age": 1
        },
        "student": 
        {
        "name": "May",
        "age": 2
        }
    }
}  

when I type the URL (eg 1.1.1.1 ), it will display the content like the above. 当我键入URL(例如1.1.1.1 )时,它将显示如上的内容。

And, in my JSP page, I have call this url in order to display the JSON content. 而且,在我的JSP页面中,我已调用此URL来显示JSON内容。 However, I don't know use WHAT object/or class to call and retrieve the file. 但是,我不知道使用WHAT对象/或类来调用和检索文件。

Does the JSP/Java provide some classes do that? JSP / Java是否提供某些类来做到这一点? Can anyone help me? 谁能帮我? Thank you. 谢谢。

You can use URLConnection to retrieve the content 您可以使用URLConnection检索内容

Here is a sample for the same 是相同的示例

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

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