Struts result param详细设置
2015-07-24 09:52
573 查看
Xml代码
<result type="json">
<!-- 这里指定将被Struts2序列化的属性,该属性在action中必须有对应的getter方法 -->
<!-- 默认将会序列所有有返回值的getter方法的值,而无论该方法是否有对应属性 -->
<param name="root">dataMap</param>
<!-- 指定是否序列化空的属性 -->
<param name="excludeNullProperties">true</param>
<!-- 这里指定将序列化dataMap中的那些属性 -->
<param name="includeProperties">
userList.*
</param>
<!-- 这里指定将要从dataMap中排除那些属性,这些排除的属性将不被序列化,一半不与上边的参数配置同时出现 -->
<param name="excludeProperties">
SUCCESS
</param>
</result>
Xml代码
<!-- 新闻跳转管理 -->
<action
name="news"
class="newsAction">
<result>/content/news/index.jsp</result>
<result
name="update"
type="json" />
<!--<result
name="detail">/content/news/detail.jsp</result>
-->
<result
name="detail"
type="json">
<param
name="includeProperties">name,list.*,feeds.*</param>
</result>
</action>
Java代码
private String name;
private INewsService newsService;
private List list;
private WeiboFeeds feeds = new WeiboFeeds();
private Map<String, Object> session;
public WeiboFeeds getFeeds() {
return feeds;
}
public void setFeeds(WeiboFeeds feeds) {
this.feeds = feeds;
}
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public INewsService getNewsService() {
return newsService;
}
public void setNewsService(INewsService newsService) {
this.newsService = newsService;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
Js代码
$("#subForm").click(function() {
var url = "news!retrieveById.action";
$.ajax({
url : url,
cache : false,
data : {
"name" : "I love You!"
},
type : "POST",
datatype : "json",
success : function(data) {
// alert(data.feeds.id);
var result = "";
$.each(data.list, function(index, value) {
result += (index + "[==]" + value[index]);
});
result += "//////////////////////\r";
$.each(data.list[1], function(index, value) {
result += (index + "[==]" + value);
});
alert(result);
}
});
});
http://www.open-open.com/lib/view/open1325518231062.html
<result type="json">
<!-- 这里指定将被Struts2序列化的属性,该属性在action中必须有对应的getter方法 -->
<!-- 默认将会序列所有有返回值的getter方法的值,而无论该方法是否有对应属性 -->
<param name="root">dataMap</param>
<!-- 指定是否序列化空的属性 -->
<param name="excludeNullProperties">true</param>
<!-- 这里指定将序列化dataMap中的那些属性 -->
<param name="includeProperties">
userList.*
</param>
<!-- 这里指定将要从dataMap中排除那些属性,这些排除的属性将不被序列化,一半不与上边的参数配置同时出现 -->
<param name="excludeProperties">
SUCCESS
</param>
</result>
Xml代码
<!-- 新闻跳转管理 -->
<action
name="news"
class="newsAction">
<result>/content/news/index.jsp</result>
<result
name="update"
type="json" />
<!--<result
name="detail">/content/news/detail.jsp</result>
-->
<result
name="detail"
type="json">
<param
name="includeProperties">name,list.*,feeds.*</param>
</result>
</action>
Java代码
private String name;
private INewsService newsService;
private List list;
private WeiboFeeds feeds = new WeiboFeeds();
private Map<String, Object> session;
public WeiboFeeds getFeeds() {
return feeds;
}
public void setFeeds(WeiboFeeds feeds) {
this.feeds = feeds;
}
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public INewsService getNewsService() {
return newsService;
}
public void setNewsService(INewsService newsService) {
this.newsService = newsService;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
Js代码
$("#subForm").click(function() {
var url = "news!retrieveById.action";
$.ajax({
url : url,
cache : false,
data : {
"name" : "I love You!"
},
type : "POST",
datatype : "json",
success : function(data) {
// alert(data.feeds.id);
var result = "";
$.each(data.list, function(index, value) {
result += (index + "[==]" + value[index]);
});
result += "//////////////////////\r";
$.each(data.list[1], function(index, value) {
result += (index + "[==]" + value);
});
alert(result);
}
});
});
http://www.open-open.com/lib/view/open1325518231062.html
相关文章推荐
- 深入Java关键字null
- 深入了解Struts2返回JSON数据的原理及具体应用范例
- Eclipse和InteliJ IDEA 使用区别
- java回调
- eclipse 上传svn 不传的内容
- 蘑菇街2015校招 Java研发笔试题 详解
- 【java】五子棋小游戏
- java 虚拟机的理解
- org.springframework.transaction.CannotCreateTransactionException
- 【连载】Maven系列(四)——配置私服
- JDK环境变量配置
- Java Socket编程
- Java语言系列03——基本数据类型
- 一种最简单的Java环境变量配置
- eclipse运行maven的jetty插件内存溢出
- Spring读取配置文件,获取bean的几种方式
- 性能分析工具Eclipse Mat
- String在java编程中使用细则
- Eclipse debug高级 技巧(转)
- Java String 比较和 Integer 比较