Witam, nie miałem styczności z frameworkiem play, mam pewien problem.
Kod error'u:
Action not found
For request 'GET /post2'
These routes have been tried, in this order:
1GET/controllers.Application.index()
2GET/listcontrollers.OrderList.showList()
3GET/postcontrollers.PostController.show()
4POST/post2controllers.PostController.sayHello()
5GET/assets/$file<.+>controllers.Assets.at(path:String = "/public", file:String)
Kod controllera:
package controllers;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import models.LogMessage;
import models.ConnectionToDB;
import com.fasterxml.jackson.databind.JsonNode;
import play.mvc.BodyParser.Json;
import play.mvc.Result;
import play.*;
import play.mvc.*;
import views.html.*;
public class PostController extends Controller {
public static Result show() {
return ok(postController.render("OK"));
}
public static Result sayHello() {
JsonNode json = request().body().asJson();
if(json == null) {
return ok(postController.render("Expecting JSON data"));
} else {
return ok(postController.render(json.textValue()));
}
}
}
oraz kod pliku route:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
GET /list controllers.OrderList.showList()
GET /post controllers.PostController.show()
POST /post2 controllers.PostController.sayHello()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
Niestety nie wiem po jakiej stronie leży problem. (Samo pobieranie z JSON'a myślę, że da rade ogarnąć), ale nie wiem dlaczego wywala mi błąd, że chce 'GET' dla post2 skoro zadeklarowałem to jako POST ;/