How to redirect to Play Framework?

When I call another action in one action, it also displays the template itself, in Play 1.1 RC and when I do Redirect("...url"), but it doesnโ€™t work, is there anyone who can help me?

+3
source share
4 answers

To add to the answers above, here is how you redirect the external URL:

public static void index () {redirects ("http://geeks.aretotally.in"); }

+12
source

To redirect, you simply call an action. From the example in the documentation :

public static void show(Long id) {
    Article article = Article.findById(id);
    render(article);
}

public static void edit(Long id, String title) {
    Article article = Article.findById(id);
    article.title = title;
    article.save();
    show(id);
}

(...) , URL-, show.

+6

/ , . conf/routes .

, , , , - .

Conf/:

GET     /admin     Application.redirect(url:'/admin/index.html')  

//Application.java:

public class Application extends Controller {

    public static void redirect(String url) {
        redirect(url, true);
    }
}
+4

, , , .

, Contoller Application

public static void index()

app/views/Application/index.html

, .

,

renderTemplate("Application/myOtherTemplate.html");

, URL- .

+3

Source: https://habr.com/ru/post/1777023/


All Articles