且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Play framework 2.0模板中插入控制器操作的链接

更新时间:2023-09-10 22:34:46

语法:

<a href='@routes.Application.show("some")'>My link with some string</a>

通过类比,您还可以在控制器中生成网址。即。在某些操作后重定向:

By analogy you can also generate urls in your controllers. ie. for redirecting after some action:

public static Result justRedirect(){

    // use as String
    String urlOfShow = routes.Application.index().toString().

    // or pass as a redirect() arg
    return redirect(routes.Application.show("some"));
}