-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