为什么struts2 ajax 方法执行两次
2014-06-13 10:02
267 查看
struts2中使用json插件执行ajax处理时,如果方法名是get方法的时候,方法会莫名其妙的执行两次。
原因: struts2 中JSON的原理是在ACTION中的get方法都会序列化,所以前面是get的方法只要没指定不序列化,都会执行解决方法
Action中的业务方法前别加get 或者 set(属性的get set 除外)
用@JSON(serialize=false)指定方法不序列化如import com.googlecode.jsonplugin.annotations.JSON;@JSON(serialize=false) public String getChild() throws Exception{ .............. .............. return "success"; }
原因: struts2 中JSON的原理是在ACTION中的get方法都会序列化,所以前面是get的方法只要没指定不序列化,都会执行解决方法
Action中的业务方法前别加get 或者 set(属性的get set 除外)
用@JSON(serialize=false)指定方法不序列化如import com.googlecode.jsonplugin.annotations.JSON;@JSON(serialize=false) public String getChild() throws Exception{ .............. .............. return "success"; }
相关文章推荐
- Struts2中action的方法被执行两次
- struts2请求两次即action方法执行两次
- Struts2中action的方法被执行两次
- struts2中Action中的方法执行两次的原因
- Struts2 请求一次Action,却执行两次方法的解决
- struts2执行2次(两次二次)action方法的解决办法
- struts2 ajax请求发现执行action两次原因
- Struts2中action的方法被执行两次
- ajax执行后台方法执行了两次
- struts2中ajax异步请求action会被自动执行两次
- struts2 下 ajax 请求被执行两次
- Struts2中的action对应的方法执行两次----解决办法
- struts2 配置测试ajax时发现action方法调用两次
- 使用struts2文件下载时,execute()方法执行两次
- Struts2标签中调用action中的方法执行hql语句的错误
- JSP、AJax中文乱码问题解决,escape(), encodeURI(), encodeURIComponent(),js对参数连续两次调用 encodeURI(String) 方法
- iframe的onload在Chrome/Opera中执行两次Bug的解决方法
- 解决Spring定时计划任务重复执行两次(实例被构造两次)问题的方法
- 在struts2下使用jQuery的Ajax方法的一些心得
- struts2 json插件执行原理 action执行两次