ssh框架中利用Ajax如何解决从服务器传到jsp页面中文乱码问题?
《-----------页面----------》functioncreateRequest(url){ alert("进入createRequest()方法"...
《-----------页面----------》function createRequest(url){ alert("进入createRequest()方法"); http_requst=false; if(window.XMLHttpRequest){ http_request=new XMLHttpRequest(); }else if(window.ActiveXObject){ try{ http_request=new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ http_request=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){} } } if(!http_request){ alert("不能创建XMLHttpRequest实例对象"); return false; } http_request.onreadystatechange=getResult; http_request.open("POST",url,true); http_request.send(null); }function getResult(){ if(http_request.readyState==4){ if(http_request.status==200){ alert(http_request.responseText); } else{ alert("您所请求的页面有错误"); } }} <input type="button" value="检验业主号是否存在" onclick="createRequest('query_pay.do?method=ajax&id='+this.form.pid.value)"> 《---------action------------------------》 public void ajax(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("进入ajax方法"); String id=request.getParameter("id"); System.out.println("id="+id); int pid=Integer.parseInt(id); String hql="select p from TbProprietorinfo as p where pId="+pid; TbProprietorinfo p=(TbProprietorinfo)objectDao.getObjectForm(hql); if(p==null){ response.setContentType("text/html"); PrintWriter out=response.getWriter(); out.print("该业主不存在,请检查后再输入 !"); } }在jsp页面得到的弹出框“该业主不存在,请检查后再输入!”为乱码,如何解决?
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询