2012-01-11 28 views
0
class SearchController { 
    def list = { 
    List<Product> productsList = productRepository.findProductBySearchPhrase(params.searchPhrase) 
    render(view: "/product/list", model: [products: productsList]) 
    } 
} 

class UrlMappings { 
    "/$controller/$action?/$id?" { 
    constraints {} 
    } 
    "/search" { 
    controller = "search" 
    view = "list" 
    constraints {} 
    } 
} 

1)该URL可正常工作,从/ views/product/list目录呈现GSP。UrlMapping导致方法不呈现不同于默认值的视图

myapp.com/search/list?searchPhrase=underware

2)此网址没有做的工作,渲染/视图/搜索/列表。

myapp.com/search?searchPhrase=underware

任何想法?

+0

我很困惑。 URL 1正在通过'search'控制器的'list'动作。但是URL 2有什么问题?它在做什么?你期望它做什么? – cdeszaq 2012-01-11 20:43:15

回答

2

也许你想在搜索URL映射中用'action'替换'view'。

+0

我在写这篇文章后就想出了它。 ;)仍然,谢谢你,为你+! – pzajdel 2012-01-12 09:29:48