response.getWriter().write()凡是能直接接jsp,html的都可以用

response.getWriter().write()

凡是能直接接jsp,html的都可以用

 

response.getWriter().write(),用这种方式可以点对点解决乱码

 写到调用这个方法的页面,如果是ajax则写到dataType:html的默认承接页面,success

回调函数中用,若果是src直接写到src中即谁调用写回给谁,<script 的src也就是引用js所以可以接收页面文件包含于标签内(此时返回给他的一般

是js代码)

 

function getMenuTree(){

alert(22);

$.ajax({

url:"${path}/tbPowerGroup/createMenuTree",

type:"post",

dataType:"html",

cache:false,

async:false,

data:{"accountid":"<%=accountId%>","path":"${path}"},

success:function(data){

$("#MenuTree").html(data);

},

error:function(retMsg){

try{

$.zd.alert('','获取菜单失败!');

}catch(eee){

}

}

});

}

 

 

@RequestMapping(value = "/createMenuTree")

public void createMenuTree(@RequestParam(value="path") String path,TbPowerGroupBeanVo to,Model model, HttpServletRequest request,HttpServletResponse response, HttpSession session) throws Exception {

System.out.println("=======================hgfhgfhgg====================="+path+"======="+to.getAccountid());

Map<String,Object> param = new HashMap<String,Object>();

Map<String,Object> paramSM = new HashMap<String,Object>();

CusUserBean getCusUser= CASUtil.getCusUser(request, session);

CusFirmBean cusfirm= tbPowerGroupBeanService.getCusFirm(getCusUser.getCustomerKey());

TbCusUserBean cus= tbPowerGroupBeanService.getTbCusUser(getCusUser.getCustomerKey());

BigDecimal userLeave =cus.getUserLevel();

Tree t = null;

String cus_trade_kind = "HA";

if(userLeave.intValue()==0){

param.put("CUSTOMER_KEY", getCusUser.getCustomerKey());

param.put("current_trade_kind", cus_trade_kind);

t=tbPowerGroupBeanService.getBigPowerMenu(param);

}else{

param.put("CUS_USER_KEY", cus.getCusUserKey());

param.put("current_trade_kind", cus_trade_kind);

t=tbPowerGroupBeanService.getSmallPowerMenu(paramSM);

}

 

 

model.addAttribute("leftMenuOfTree",new String(encapLeftMenuTreeJs(t,to.getAccountid(),path).getBytes("ISO-8859-1"),"UTF-8"));

response.setCharacterEncoding("UTF-8");

response.getWriter().write(encapLeftMenuTreeJs(t,to.getAccountid(),path));

System.out.println("=nihao =");

//return "/myaccount/myaccountMenuTree";

}

猜你喜欢

转载自yuhuiblog6338999322098842.iteye.com/blog/2322290