问题描述
- html里form体检的中文如何从二进制恢复成中文
-
我自己用seversocket写了个服务端,想把html里的form体交内容提交到服务端,但是接受到的数据好像是二进制格式的,我用字节数组bytes接收,然后用了new String(bytes,0,bytes.length)想把它恢复成普通的字符串,但是为何里面的中文体检信息成了%B2%E3%D5之类的,我该如何把它恢复
解决方案
解码吧,好像有个decodeURIC....的函数我忘记怎么写了,你百度看看吧,不知道对不对,只有点印象
解决方案二:
第一次提问,有什么不对的地方请指出
解决方案三:
计算机里的数据底层都是二进制。你说的提交到服务端的数据是流吧。
解决方案四:
package sever;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class SeverDemo {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
ServerSocket server = new ServerSocket(8888);
while (true) {
Socket socket = server.accept();
InputStream in = socket.getInputStream();
byte[] buf = new byte[1024];
int len = in.read(buf);
System.out.println(new String(buf, 0, len));
PrintWriter p = new PrintWriter(socket.getOutputStream(), true);
p.println("<font color='green' size='10'>注册成功</font>");
socket.close();
}
//server.close();
}
}
//服务器端代码
解决方案五:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Untitled Document
查询信息
学号:
返回首页>>
html代码
解决方案六:
POST / HTTP/1.1
Host: 127.0.0.1:8888
Connection: keep-alive
Content-Length: 11
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: null
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8
d=%E9%83%AD
GET /favicon.ico HTTP/1.1
Host: 127.0.0.1:8888
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Accept: /
Referer: http://127.0.0.1:8888/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
这是提交的结果