Search code examples
grailsviewrendergspurl-mapping

UrlMapping causing method not to render different view than default


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) This URL works properly, rendering GSP from /views/product/list directory.

myapp.com/search/list?searchPhrase=underware

2) This URL doesn't do the work, rendering /views/search/list.

myapp.com/search?searchPhrase=underware

Any ideas?


Solution

  • May be you want to replace 'view' with 'action' in the search URL Mapping.