1. 客户端jQuery代码   

 页面上负责发送Post请求的jQuery代码如下:

$.ajax({
  type: "POST",
  url: "/receive",
  data: $("#data").val(),
  contentType: "text/plain", 
  processData: false,
  success: function(res){
    $("#mess").text(res);
  }
});
 这里需要注意的是第5行,将contentType设置为 text/plain,Play会根据contentType解析请求数据,
contentType: "text/plain"


2. 服务端Play代码

 routes文件中配置:
POST /receive controllers.Application.receive
 Action代码:
def receive = Action { request =>
    val content = request.body.asText.get
    Ok("Receive: " + content)
}

  这里需要注意的是获取请求数据的方法调用:request.body.asText,如果Post请求的contentType不是text/plain,则该方法调用将会返回None,进而导致get方法报错。

Recommend:How to make internal synchronous post request in Play framework and scala

to make post call internally to get data from my server. But this should be synchronous. After getting the data from this post request, I need to send that data to front end. I've seen many resources but all are asynchro

ori:http://my.oschina.net/joymufeng/blog/346639