java,nickname=new String(nickname.getBytes("iso-8859-1"),"utf-8"); 为何这样操作呢?
java中:..............................List<NameValuePair>params=newArrayList<NameValueP...
java中:..............................
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("param", "post"));
params.add(new BasicNameValuePair("nickname", nickname.getText()
.toString()));
params.add(new BasicNameValuePair("content", content.getText()
.toString()));
try {
httpRequest.setEntity(new UrlEncodedFormEntity(params, "utf-8"));//////
.........................................
后台jsp:..............
nickname=new String(nickname.getBytes("iso-8859-1"),"utf-8"); //对昵称进行转码?????
content=new String(content.getBytes("iso-8859-1"),"utf-8"); //对内容进行转码?????
....................................
/////前面用了utf-8编码,这边怎么又先用iso-8859-1把字符串转化为字节数组,又用utf-8把字节数组转换为字符串,为什么这样做呢??? 展开
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("param", "post"));
params.add(new BasicNameValuePair("nickname", nickname.getText()
.toString()));
params.add(new BasicNameValuePair("content", content.getText()
.toString()));
try {
httpRequest.setEntity(new UrlEncodedFormEntity(params, "utf-8"));//////
.........................................
后台jsp:..............
nickname=new String(nickname.getBytes("iso-8859-1"),"utf-8"); //对昵称进行转码?????
content=new String(content.getBytes("iso-8859-1"),"utf-8"); //对内容进行转码?????
....................................
/////前面用了utf-8编码,这边怎么又先用iso-8859-1把字符串转化为字节数组,又用utf-8把字节数组转换为字符串,为什么这样做呢??? 展开
推荐于2018-03-01
展开全部
因为 JSP 默认取到的是iso-8859-1的,所以要先按iso-8859-1取出来,再转成utf-8
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询