在*.js文件中提交action传参,接收时乱码问题



在*.js文件中提交action传参,接收时乱码问题

现象:在*.js文件中提交action,

 

          fm.action=’A.jsp?strStatus=’+strStatus+’&strXmlText=’+strXmlText;

 

          fm.submit();

 

          在A.jsp页面:

 

          String strMessage = request.getParameter(“strStatus”);

 

          String strXmlText = request.getParameter(“strXmlText”);


 

          strStatus和strXmlText都为乱码。

 

原因:

 

          在*.js文件中提交action时,对参数进行自动编码URLEncoder.encode(),并且字符集默认为“utf-8”的形式,在接收时没有解码操作,导致乱码。

 

解决方法:

 

        在A.jsp文件中进行解码操作。URLDecoder.decode(request.getParameter(“strStatus”), “utf-8″);乱码问题解决