在struts2的Action中返回Ajax显示需要的信息
来源:百度文库 编辑:神马文学网 时间:2024/04/19 19:52:12
概要:
如何在struts2的action中返回数据(普通字符串、xml数据岛字符串等)给ajax核心中的XMLHttpRequest对象(即模仿传统jsp页面的ajax交互)
方法:
public String execute() throws Exception {
String str="xxoohuai";
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=GBK");//解决中文乱码
PrintStream out = new PrintStream(response.getOutputStream());//获取out输出对象
out.println(str);
return null;//这里返回的是null
}
配置struts.xml
ok~~~~~~~~!
补充:实习后发觉这样更简单
getResponse().getWriter().write("your output String");
struts.xml配置连result标签都不用写了
如何在struts2的action中返回数据(普通字符串、xml数据岛字符串等)给ajax核心中的XMLHttpRequest对象(即模仿传统jsp页面的ajax交互)
方法:
public String execute() throws Exception {
String str="xxoohuai";
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=GBK");//解决中文乱码
PrintStream out = new PrintStream(response.getOutputStream());//获取out输出对象
out.println(str);
return null;//这里返回的是null
}
配置struts.xml
ok~~~~~~~~!
补充:实习后发觉这样更简单
getResponse().getWriter().write("your output String");
struts.xml配置连result标签都不用写了
在struts2的Action中返回Ajax显示需要的信息
在struts2的Action中返回Ajax显示需要的信息2
Struts2中使用注解 管理Action方法的权限
Struts2中struts.xml的Action配置详解
struts2的ajax支持,ajax校验
Struts2的使用注解配置Action
struts2配置中Action的name 和package的name和namespace是什么作用
struts2配置中Action的name 和package的name和namespace是什么作用
需要在JS中修改form的action属性,但form里面有个控件也叫action,我的处...
Struts2 的 Action 被 无故 执行2次 或 执行多次
Struts2需要注意的一个小地方
sajax.php在php中实现ajax技术的类
在VS2005中通过Ajax调用WebService遇到的问题
sajax.php在php中实现ajax技术的
sajax.php在php中实现ajax技术的类
显示手机信息的手表
在struts2中使用JFreeChartdasdasd
struts2怎么做forward-action?
Struts中不同的Action和ActionForm组合
怎样在EXCE中引用另一工作表中某一单元格的返回值统计及格人数
QTP的Action间的信息共享的4种方法
返回古典就是返回我的六经
关于中国军队中朝鲜族官兵返回朝鲜的历史考察
DWR中Java方法的参数及返回值