日期:2014-05-17 浏览次数:20619 次
//这个是根据ID查询出来的一个Name public ActionForward getNameBySID(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); String deptName = ""; String deptLevel = request.getParameter("deptLevel"); //String deptLevel ="0001"; try { deptName = deptService.GetDeptNameByDeptLevel(deptLevel); } catch (BusinessServiceException e) { e.printStackTrace(); } System.out.println(deptName+"&&&&&&&"+deptLevel); JSONObject json = new JSONObject(); json.put("json", deptName); return null; }
function onNodeSelect(sID){ alert(sID); if(sID.indexOf("000")==0){ $.ajax({ type:"post", url:"${pageContext.request.contextPath}/measureWorkflow.do", cache:false, dataType:"json", data:"method=getNameBySID&deptLevel="+sID, success:function(data){ alert(${deptName}); window.frames["process"].document.write ('<input type="text" value="aa"><br>'); } }); } }
JSONObject json = new JSONObject(); json.put("json", deptName); return json;
------解决方案--------------------
呵呵,你的问题缺一个关键的东东:
response.setCharacterEncoding("utf-8");//编码
response.getWriter().print(json.toString());//输出
------解决方案--------------------
response.getWriter().print(json.toString());//输出
------解决方案--------------------
后台品字符串成为JSON格式 然后使用AJAX返回到页面。