2013-03-21 35 views
0

在我的我的控制器的方法之一,被稱爲PageController,我有play-framework 2.0,是否可以通過反向路由器添加GET變量?

return redirect(routes.PageController.page_view("main", "home")); 

這正好/main/home。我如何添加一個GET變量到這個,所以它應該例如去/main/home?redirect=0之類的東西?

+0

請註明問題,如果你有一個答案或張貼你的答案,以幫助其他人在未來 – adis 2013-03-28 08:00:26

回答

1

我也做了同樣的,如果我明白你的問題:

public static Result GO_TO_OVERVIEW = redirect(routes.Bookmarks.index(0, "description", "asc", "")); 

我的路線聲明,這看起來像:

GET  /bookmarks controllers.Bookmarks.index(p:Int ?= 0, s ?= "description", o ?= "asc", f ?= "") 

而且我的索引功能:

public static Result index(int page, String sortBy, String order, String filter) { 
    if (sortBy.isEmpty() || sortBy == null) { 
     page = 0; 
     sortBy = "description"; 
     order = "asc"; 
    } 
    User user = User.getLoggedInUser(session("user")); 
    Page<models.Bookmark> orderList = models.Bookmark.page(page, 20, sortBy, order, filter, user); 
    return ok(views.html.bookmarks.list.render(orderList, sortBy, order, filter)); 
} 

它適合你嗎?

+0

嗨,是啊,我得到它的工作,我輸入了我的路由器'GET \t \t /中:namespace /:命名\t \t \t \t controllers.Application.page_view(namespace:String,name:String,redirect:Boolean?= true)'這讓我可以選擇在我想要的時候傳遞布爾值,乾杯 – area5one 2013-03-23 19:40:48

相關問題