Struts result param详细设置
- <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>
- <!-- 新闻跳转管理 -->
- <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>
- 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;
- }
- $("#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