Struts2 Ajax---Action传值到JSP页面 Json格式
来源:互联网 发布:安卓arm linux打开端口 编辑:程序博客网 时间:2024/05/08 08:00
转载自:http://blog.sina.com.cn/s/blog_a345a8960101krct.html
有几个必须要的包
ezmorph-1.0.3.jar
json-lib-2.1.jar
struts2-json-plugin-2.1.8.1.jar
commons-lang-2.4.jar
commons-beanutils-1.7.0.jar
Action部分
@Controller
public class LookAction extends ActionSupport {
private int thispage; //设置私有变量,用于接受Jsp页面Ajxa传参(get、set方法要写上)
public int getThispage() {
return thispage;
}
public void setThispage(int thispage) {
this.thispage = thispage;
}
private JSONArray jarray; //创建JSONArray 用于向页面传递Json格式数据(get、set方法要写上)
public JSONArray getJarray() {
return jarray;
}
public void setJarray(JSONArray jarray) {
this.jarray = jarray;
}
@Resource LookServiceImp lookService;
@Override
public String execute() throws Exception {
Page page = new Page(thispage, 8);//Page分页工具类
List list = (List)lookService.getPage(page); //调用ServiceImp得到查询对象集合
JSONArray json = new JSONArray().fromObject(list);//创建JSONArray 用fromObject方法装入list集合
jarray = json; //把集合对象转化为Json格式集合对象
return SUCCESS;
}
}
Struts.xml
<!-- 引用Json类型 成功后传递Action中编译好的json格式对象 -->
Jsp页面接收
$.post("look.action",
{thispage:page,},
function(data){
alert(list.id)
}
});
0 0
- Struts2 Ajax---Action传值到JSP页面 Json格式
- struts2中使用json格式ajax与后端action交互
- Struts2三种传参体式格式(从jsp页面传到Action)
- struts2 action返回json格式
- 在struts2中从jsp页面传值到action中
- 在struts2中从jsp页面传值到action中
- 在struts2中从jsp页面传值到action中
- 在 struts2中从jsp页面传值到action中
- 在struts2中从jsp页面传值到action中
- struts2中jsp页面传值到action方式总结
- struts2中jsp页面传值到action方式总结
- struts2中jsp页面传值到action方式总结
- struts2中jsp页面传值到action的两种方式
- struts2中jsp页面传值到action方式总结
- struts2使用ajax实现页面和action之间通过json数据交互
- struts2项目jsp页面通过js调取action中的封装的json
- struts2中action获取jsp页面参数
- Struts2--JSP页面和Action的交互
- Google breakpad
- nginx.conf详解[转]
- eclipse下git不能拉取错误解决小记
- Linux命令整理--find命令(一)
- 荀子·劝学篇
- Struts2 Ajax---Action传值到JSP页面 Json格式
- startActivityForResult和setResult详解
- eclipse开发用ant生成myeclipse那样的执行文件夹
- SqlServer2000中nvarchar和varchar的区别
- Nginx+Lua访问Redis
- flipdim函数
- 表达式求值
- Objective-c的copy和mutableCopy
- TranslateAnimation动画结束后控件移动位置