java - How to correct change encoding of post query? -
when send post page without setcharacterencoding on server-side, фыв. setcharacterencoding(utf-8), ыва. how correct change character encoding of post query?
p.s.: read data servletinputstream.
code below.
dopost req.setcharacterencoding("utf-8"); bufferedreader r = new bufferedreader(new inputstreamreader(req.getinputstream())); string line; while ((line = r.readline()) != null) { system.out.println(line); }
bufferedreader r = new bufferedreader( new inputstreamreader(req.getinputstream(), standardcharsets.utf_8)); with getinputstream have binary data without encoding. hence binary-to-text bridging class inputstreamreader needs correct encoding. otherwise uses system default system.getproperty("file.encoding").
Comments
Post a Comment