Struts result param详细设置
生活随笔
收集整理的這篇文章主要介紹了
Struts result param详细设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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>??
<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>??
<!-- 新聞跳轉管理 --><actionname="news"class="newsAction"><result>/content/news/index.jsp</result><resultname="update"type="json" /><!--<resultname="detail">/content/news/detail.jsp</result>--><resultname="detail"type="json"><paramname="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;?? ????}??
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);?? ????????????????????????????}?? ????????????????????????});?? ????????????});??
$("#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);}});});
Xml代碼 ?
Java代碼 ?
Js代碼 ?
總結
以上是生活随笔為你收集整理的Struts result param详细设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: u盘显示不可以写入怎么解决 解决U盘无法
- 下一篇: SSh结合Easyui实现Datagri