您的位置:首页 > 编程语言 > Java开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: