3
votes

How can I add an URL fragment (#xyz) to a link created by the Redirect method?

I want something like this:

Redirect(routes.Comment.get(itemId) + "#xyz")
2

2 Answers

2
votes

You can get the url form the route using .url (which contains a relative url). Redirect needs two parameters to accept a string to redirect to

so, Redirect(routes.Comment.get(itemId).url + "#xyz", SEE_OTHER) should work

Edited when I realized Redirect() takes a Call and not a string

2
votes

With Play Framework 2.4 is possible do this:

Redirect(routes.Comment.get(itemId).withFragment("#xyz").toString)