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页面得到的弹出框“该业主不存在,请检查后再输入!”为乱码,如何解决?   展开
 我来答
erliang20088
2011-10-11 · TA获得超过2496个赞
知道小有建树答主
回答量:926
采纳率:100%
帮助的人:915万
展开全部
只要确定数据库和程序的页面也是utf-8编码,只要再写一个servlet filter过滤器,用于设置encoding为utf-8就可以了,这种方法是屡试不爽,试试吧,如果你学了ssh了的话,过滤器应该可以搞定的~
zzxiaoma
2011-10-11
知道答主
回答量:14
采纳率:0%
帮助的人:9.9万
展开全部
工程里面加过滤器
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式