转载
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的数组
Struts2+JQuery+Json及JQuery相关插件的例子_IT/计算机_专业资料。Struts2+...</struts> 2.ShowAction.java 配置 : view plaincopy to clipboardprint? 1. ...
通过代码示例学习JSon在Java和Struts2中的应用技术_计算机软件及应用_IT/计算机_专业资料。作者根据自身多年的软件开发实践和经验总结,结合多年的IT职业培训的教学和...
14.4.2 JSON 插件 为了更容易使用 JSON,Struts2 提供了 JSON 插件,这个插件...属性的值设置到 div 中显示即可,示例代码如下: java 代码:查看复制到剪贴板...
import java.util.ArrayList; import java.util.List; import net.sf.json.JSONObject; import org.apache.struts2.ServletActionContext; import com.open...
java培训-Struts2 json插件的使用_计算机软件及应用_IT/计算机_专业资料。Struts2 json 插件的使用废了一天的功夫,终于把我的留言功能实现了.有时候一个纠结的...
在Struts2 中要使用 Ajax 获得 Json 数据我认为...Java 对象转换成 Json 字符串再写往 Response 去,...JSON 插件提供了一个 "json" 结果类型来把 action...
以下是 index.jsp 文件中的代码: <%@ page language="java" import="java....sj:select 组件该组件必须与 struts2 的 json 插件一起使用。 向 Action 发送...
Struts2_插件JSON Plugin_计算机软件及应用_IT/计算机_专业资料。Introduction The JSON plugin provides a "json" result type that serializes actions into JSON...
java-struts2.0经典知识点_计算机软件及应用_IT/...(Tag) 而言, 使用以下例子来说明三者之间的关系。 ...并且 JQuery 使用了插件的体系结构,开发人员可以在 ...
辽宁石油化工大学计算机与通信工程学院 一.实验目的: 1.掌握 Struts2 配置 2.掌握 Struts2 标签库的使用; 3.掌握 Action 编写 二.实验内容: 编写一个小型留言...
热门文档