Play Framework - Redirect with params

前端 未结 2 1842
南方客
南方客 2021-02-13 03:01

I am trying to figure out how to do a redirect within a controller action in Play (2.0) using Scala.

The redirect using

Redirect(routes.Application.index         


        
相关标签:
2条回答
  • 2021-02-13 03:42

    You can also avoid creating another function just for this in your controller. In your route config, you can simply add something like this:

      GET  /google  @controllers.Default.redirect(to = "http://google.com")
    
    0 讨论(0)
  • 2021-02-13 03:46

    Ellou'

    A route is just a function, so you can pass arguments as usual:

    // Redirect to /hello/Bob
    def helloBob = Action {
        Redirect(routes.Application.hello("Bob"))    
    }
    

    This snippet comes from http://www.playframework.org/documentation/2.0/ScalaRouting (at the bottom)

    0 讨论(0)
提交回复
热议问题