-1
我有一个简单的http服务器,我需要通过Stream
发送String
。但是,字符串包含空格,我知道如何从Stream
的客户端写入它。我如何在Server
方接收它?如何将字符串发送到Http服务器(Java)
static class InsertPostHandler implements HttpHandler {
public void handle(final HttpExchange HE) throws IOException {
Thread thread = new Thread(new Runnable() {
final HttpExchange t = HE;
@Override
public void run() {
Statement stmt = null;
// add the required response header for a PDF file
String Request =(t.getRequestURI().toString()
.split("\\/@@postssystem/"))[1];
System.out.println(Request);
if(Request.equals("createpost")){
Headers h = t.getResponseHeaders();
h.add("Content-Type", "Image");
h.add("Cache-Control","must-revalidate");
//Here I Need To Receive A String
try {
t.sendResponseHeaders(200,1);
} catch (IOException e) {
e.printStackTrace();
}
但如何接收字符串伴侣吗? – reza 2014-08-30 13:52:09
在服务器端,您可以使用'HttpServletRequest'来获取请求参数。 – 2014-08-31 06:18:23