Skip to content

Instantly share code, notes, and snippets.

@supunsandeeptha
Created May 24, 2019 18:28
Show Gist options
  • Save supunsandeeptha/7fbd91fc2e7a39761042ef16eafd7319 to your computer and use it in GitHub Desktop.
Save supunsandeeptha/7fbd91fc2e7a39761042ef16eafd7319 to your computer and use it in GitHub Desktop.
package controllers;
import com.fasterxml.jackson.databind.JsonNode;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
public class HomeController extends Controller{
public Result index() {
return ok();
}
//addbook method
public Result sendName(){
JsonNode body = request().body().asJson();
String name = body.get("name").asText();
System.out.println("Server has received the name " + name);
return ok(Json.toJson("Your name is //// this is from server " + name));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment