一、js
jQuery.ajax({
type:"POST",
url:"",
async:false, //同步,须后台执行完才能进行其他操作
data:{objectId:"1"},
success:function(str){
alert(str);
},
error:function(){
alert("失败!");
}
});
二、struts2配置
三、Action代码
public String getData() throws IOException{
str="abc测试";
HttpServletResponse response=ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8"); // 加上此处可解决页面js显示乱码问题
response.getWriter().write(str); return null; }