问题描述
- request.getParameter()的乱码问题
-
String selProvince = request.getParameter("parProvince");
selProvince = new String(selProvince.getBytes("ISO-8859-1"),"UTF-8");
System.out.println(selProvince);
输出的是????
jsp文件是<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
解决方案
jsp request.getParameter()乱码问题 乱码
JSP中request.getParameter()乱码问题
JSP中request.getParameter()乱码问题
解决方案二:
request..setCharacterEncoding("utf-8"),,这样,你再试试
解决方案三:
没有用啊,我改了好久
解决方案四:
request.setCharacterEncoding("UTF-8");
解决方案五:
request.setCharacterEncoding("UTF-8");
解决方案六:
Web.xml 查看一下是不是UTF-8
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
查看一下发送过来是不是原本就是乱码。
解决方案七:
function getCity(selProvince){
alert(selProvince);
var loader = new net.AjaxRequest("LiveServlet?action=getCity&parProvince="+selProvince+"&nocache="
+new Date().getTime(),deal_getCity,onerror,"GET");
}
我在这里查了不是乱码,在web.xml中是
setCharacterEncodingFilter
org.apache.catalina.filters.SetCharacterEncodingFilter
encoding
UTF-8
true
解决方案八:
URLDecoder.decode(selProvince,"UTF-8");你这样试试看,百分百可以的,不用谢!
解决方案九:
前台转码,后台解码
例如:前台jsp中:
var groupBuyerName = document.getElementById('groupBuyerName').value;
groupBuyerName = encodeURI(encodeURI(groupBuyerName));
后台java类中:
String groupBuyerName = request.getParameter("groupBuyerName")
groupBuyerName=URLDecoder.decode(groupBuyerName,"utf-8");
解决方案十:
前台转码,后台解码
例如:前台jsp中:
var groupBuyerName = document.getElementById('groupBuyerName').value;
groupBuyerName = encodeURI(encodeURI(groupBuyerName));
后台java类中:
String groupBuyerName = request.getParameter("groupBuyerName")
groupBuyerName=URLDecoder.decode(groupBuyerName,"utf-8");