从java发布请求到php

I have a problem ,when I send a post request from java to web server .But when I use GET method it works very well .

java code

   package networkTest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;

public class Main {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
        URL url=new URL("http://127.0.0.1/index.php");
        HttpURLConnection curl=(HttpURLConnection) url.openConnection();
        curl.setDoInput(true);
        curl.setDoOutput(true);
        curl.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
        curl.setAllowUserInteraction(true);

        curl.setRequestMethod("POST"); //**
        OutputStream out =curl.getOutputStream();
        InputStream in =curl.getInputStream();
        String data="name=xxx";
        out.write(data.getBytes());

        InputStreamReader reader=new InputStreamReader(in);
        BufferedReader Breader=new BufferedReader(reader);
        String buff;
        String Rdata="";
        while((buff=Breader.readLine()) !=null )
        {
            Rdata+=buff+"
";
        }
        System.out.println(Rdata);




    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        System.err.println("error in url connection");
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        System.err.println("IO execption: error in opening connection");
        e.printStackTrace();
    }



  }
}

PHP code I received a response from inputstream but the $_POST["name"] is always unset and the response is always "there is no request "

<?php
    if(isset($_POST["name"]))
    {
        echo($_POST["name"]);
    }
    else
    {
        echo"there is no request";
    }
?>