struts2 ajax請求發現執行action兩次緣由

struts2中使用json插件執行ajax處理時,若是方法名是get方法的時候,方法會莫名其妙的執行兩次。 ajax

緣由: struts2 中JSON的原理是在ACTION中的get方法都會序列化,因此前面是get的方法只要沒指定不序列化,都會執行解決方法json

  • Action中的業務方法前別加get 或者 set(屬性的get set 除外) jsonp

  • 用 @JSON(serialize=false)指定方法不序列化如import com.googlecode.jsonplugin.annotations.JSON;@JSON(serialize=false) public String getChild() throws Exception{ .............. .............. return "success"; }google

相關文章
相關標籤/搜索