The documentation here PlayFramework JavascriptRouting says to use play.Routes:
import play.mvc.Controller;
import play.mvc.Result;
import play.Routes;
public Result javascriptRoutes() {
return ok(
Routes.javascriptRouter("jsRoutes",
routes.javascript.Users.list(),
routes.javascript.Users.get()
)
).as("text/javascript");
}
However, the JavaDocs say that Routes is deprecated, and suggests using JavaScriptReverseRouter.create, for which I find the documentation confusing, and I can't find any examples or tutorials anywhere. Can someone please clarify?
Try this:
return ok(
JavaScriptReverseRouter.create("jsRoutes",
routes.javascript.Users.list(),
routes.javascript.Users.get()
)
).as("text/javascript");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.