cookie先天不能写中文,令人很郁闷下面的方法可以解决
- 摘要:importjava.net.*;Stringkey=URLEncoder.encode("中文key","GBK");Stringvalue=URLEncoder.encode("中文value","GBK");Cookiecook=newCookie(key,value);Stringkey=cook.getName(),value=cook.getValue();key=URLDecoder.decode(key,"GBK");value=URLDecoder.decode(value
- 标签:方法 解决 Cookie
import java.net.*;
String key=URLEncoder.encode("中文key","GBK");
String value=URLEncoder.encode("中文value","GBK");
Cookie cook=new Cookie(key,value);
String key=cook.getName(),value=cook.getValue();
key=URLDecoder.decode(key,"GBK");
value=URLDecoder.decode(value,"GBK");