Search code examples
grailsgrails-controller

Grails. Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'


I'm getting started with Grails (3.x) Framework but I got stuck with this error while trying to render domain content to a view:

Error 500: Internal Server Error
URI /hello/index
Class javax.servlet.ServletException
Message: Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'

HelloController.groovy:

package helloworld   
class HelloController {

    def index() {
        def Person persona1 = new Person(firstName: "someone", lastName: "stuck", age: 21)
        [persona:persona1]
    }
}

Person.groovy:

package helloworld

class Person {
    String firstName
    String lastName
    int age
}

Solution

  • Make sure that grails-app/views/hello/index.gsp file exists.