在Java Web应用程序中使用Json和Gson

时间:2021-04-12 13:41:54

Hi could anyone please explain me,When we need to use JSon or Gson. What would be the scenario?Could it possible to use Gson or Json in request scope attribute or only during ajax response in the application.

嗨,有人可以解释我,当我们需要使用JSon或Gson。会是什么情况?是否可以在请求范围属性中使用Gson或Json,或者仅在应用程序中的ajax响应期间使用。

2 个解决方案

#1


0  

Along with ajax json can be used as a request.setAttribute and also you can retrieve the json between servlet and JSP. Check this link out for your understanding..

与ajax一起使用json可以用作request.setAttribute,也可以检索servlet和JSP之间的json。请查看此链接以了解您的情况..

http://spritiuallyjava.blogspot.in/2012/07/json-with-jsp-and-servlets.html

#2


0  

You can use Gson (library) to generate a JSON (format) object that you can use with anything that needs a JSON representation of an object. In Java web applications, this is often for AJAX responses.

您可以使用Gson(库)生成JSON(格式)对象,您可以将其用于需要对象的JSON表示的任何内容。在Java Web应用程序中,这通常用于AJAX响应。

#1


0  

Along with ajax json can be used as a request.setAttribute and also you can retrieve the json between servlet and JSP. Check this link out for your understanding..

与ajax一起使用json可以用作request.setAttribute,也可以检索servlet和JSP之间的json。请查看此链接以了解您的情况..

http://spritiuallyjava.blogspot.in/2012/07/json-with-jsp-and-servlets.html

#2


0  

You can use Gson (library) to generate a JSON (format) object that you can use with anything that needs a JSON representation of an object. In Java web applications, this is often for AJAX responses.

您可以使用Gson(库)生成JSON(格式)对象,您可以将其用于需要对象的JSON表示的任何内容。在Java Web应用程序中,这通常用于AJAX响应。