No, this is not possible, there are two solutions.
First , 2 names are used:
public static Result getByLong(Long id) {
return ok("Long value: " + id);
}
public static Result getByString(String name) {
return ok("String value: " + name);
}
also you must use separate routes for it, otherwise you will get a type mismatch
GET /p-by-long/:id controllers.Monitor.getByLong(id: Long)
GET /p-by-string/:name controllers.Monitor.getByString(name: String)
String , Long
public static Result getByArgOfAnyType(String arg) {
try {
Long.parseLong(arg);
return ok("Long: " + arg);
} catch (Exception e) {
return ok("String: " + arg);
}
}
:
GET /p/:arg controllers.Monitor.getByArgOfAnyType(arg : String)
, , , , . , , String , : , String Java?