文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > java相关的Struts2-Json插件的使用例子
侵权投诉

java相关的Struts2-Json插件的使用例子

转载

The JSON plugin provides a "json" result type that serializes actions into JSON. The serialization process is recursive, meaning that the whole object graph, starting on the action class (base class not included) will be serialized (root object can be customized using the "root" attribute). If the interceptor is used, the action will be populated from the JSON content in the request, these are the rules of the interceptor:

The "content-type" must be "application/json"

The JSON content must be well formed, see for grammar. Action must have a public "setter" method for fields that must be populated.

Supported types for population are: Primitives (int,long...String), Date, List, Map, Primitive Arrays, Other class (more on this later), and Array of Other class.

Any object in JSON, that is to be populated inside a list, or a map, will be of type Map (mapping from properties to values), any whole number will be of type Long, any decimal number will be of type Double, and any array of type List.

JSON插件提供一种叫做“json”返回类型,来将action序列化成JSON格式。序列化过程是递归的,这意味着整个对象图(从action开始,父类不会被序列化)都会被序列化(根对象可以通过“root”属性来自定义)。如果设置了拦截器,action将被请求中的JSON填充,下面是拦截器的规则:

1.请求的"content-type"必须为"application/json" 2.JSON内容必须是格式良好的,语法参见json.org 3.Action中被填充的属性必须要有一个setter方法

4.可以被填充的类型包括:原生类型(),Date,List, Map, 原生数组,其他class,和其他class的数组

第1页

你可能喜欢

  • java例子
  • java案例
  • java常用类
  • javaweb
  • 椭圆例题
  • java开发
  • java设置

热门文档

相关文档

  • Struts2+JQuery+Json及JQuery相关插件的例子

    Struts2+JQuery+Json及JQuery相关插件的例子_IT/计算机_专业资料。Struts2+...</struts> 2.ShowAction.java 配置 : view plaincopy to clipboardprint? 1. ...

  • 通过代码示例学习JSon在Java和Struts2中的应用技术

    通过代码示例学习JSon在Java和Struts2中的应用技术_计算机软件及应用_IT/计算机_专业资料。作者根据自身多年的软件开发实践和经验总结,结合多年的IT职业培训的教学和...

  • 使用JSON插件

    14.4.2 JSON 插件 为了更容易使用 JSON,Struts2 提供了 JSON 插件,这个插件...属性的值设置到 div 中显示即可,示例代码如下: java 代码:查看复制到剪贴板...

  • Struts2+json的一个例子

    import java.util.ArrayList; import java.util.List; import net.sf.json.JSONObject; import org.apache.struts2.ServletActionContext; import com.open...

  • java培训-Struts2 json插件的使用

    java培训-Struts2 json插件的使用_计算机软件及应用_IT/计算机_专业资料。Struts2 json 插件的使用废了一天的功夫,终于把我的留言功能实现了.有时候一个纠结的...

  • 在Struts2 中要使用 Ajax 获得 Json 数据我认为目前还...

    在Struts2 中要使用 Ajax 获得 Json 数据我认为...Java 对象转换成 Json 字符串再写往 Response 去,...JSON 插件提供了一个 "json" 结果类型来把 action...

  • Struts2-14使用JQuery插件(1)

    以下是 index.jsp 文件中的代码: <%@ page language="java" import="java....sj:select 组件该组件必须与 struts2 的 json 插件一起使用。 向 Action 发送...

  • Struts2_插件JSON Plugin

    Struts2_插件JSON Plugin_计算机软件及应用_IT/计算机_专业资料。Introduction The JSON plugin provides a "json" result type that serializes actions into JSON...

  • java-struts2.0经典知识点

    java-struts2.0经典知识点_计算机软件及应用_IT/...(Tag) 而言, 使用以下例子来说明三者之间的关系。 ...并且 JQuery 使用了插件的体系结构,开发人员可以在 ...

  • java基于Struts2的留言板程序

    辽宁石油化工大学计算机与通信工程学院 一.实验目的: 1.掌握 Struts2 配置 2.掌握 Struts2 标签库的使用; 3.掌握 Action 编写 二.实验内容: 编写一个小型留言...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email