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。

myapp.com/search/list?searchPhrase=underware

2) 这个 URL 不起作用,渲染 /views/search/list。

myapp.com/search?searchPhrase=underware

有任何想法吗?

4

1 回答 1

2

可能您想在搜索 URL 映射中将“视图”替换为“操作”。

于 2012-01-11T22:47:43.887 回答