java前台向后台传值中文乱码问题解决

1:从jsp页面向后台传值

jsp:">

java:

String str=request.getParameter("search");

                if(str != null){

String searchName =null;

try{

      strsearch=new String(str.getByte("iso-8859-1"),"gb2312");

}catch(UnsupportedEncodingException e){

e.printStackTrace();

}

parms.put("searchName",searchName);

}

2:从js向后台传值

js: var url="<%path%>/kqbj="+encodeURI(encodeURI("牙"));

java:

String str=request.getParameter("search");

                if(str != null){

String searchName =null;

try{

      strsearch=URLDecoder.decode(str,"utf-8")

}catch(UnsupportedEncodingException e){

e.printStackTrace();

}

parms.put("searchName",searchName);

}



你可能感兴趣的:(JAVA,JS)