2

I am not able to open the controller on grails project

I am using the following versions of groovy and grails

C:\Users\Two95Admin>grails -version Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this releas| Grails Version: 3.1.10 | Groovy Version: 2.4.7 | JVM Version: 1.8.0_74 C:\Users\Two95Admin>

I have successfully created the helloworld project using following commands

grails create-app helloworld cd helllworld grails create-controller hello run-app

My project is executed on localhost:8080 Screenshot of an Error Screen

Error 500: Internal Server Error

URI /hello/index Class javax.servlet.ServletException Message Could not resolve view with name '/hello/index' in servlet with name 'grailsDispatcherServlet'

Trace

Line | Method

->> 1229 | render in org.springframework.web.servlet.DispatcherServlet


| 1029 | processDispatchResult in '' | 973 | doDispatch . . . . . in '' | 895 | doService in '' | 967 | processRequest . . . in org.springframework.web.servlet.FrameworkServlet | 858 | doGet in ''

Please help me solving the problem

tim_yates
  • 167,322
  • 27
  • 342
  • 338
SM ANSARI
  • 335
  • 3
  • 13

2 Answers2

2

It looks like grails-app/views/hello/index.gsp does not exist. You will need to create that file.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • 1
    index.jsp file is located there. but still it is not working – SM ANSARI Aug 22 '16 at 16:14
  • Try creating an 'index.gsp' file (gsp, not jsp), whose contents are simply

    Should be simple

    . I just created an app using 3.1.10 and generated the controller as you did, then created an index.gsp file as suggested by JSB. Worked fine displaying that message at the url of "http://localhost:8080/hello/index".
    – railsdog Aug 22 '16 at 17:02
  • Thanks for the help. Actually I have to create jsp file should be inside the view/hello folder – SM ANSARI Sep 19 '16 at 03:54
  • @SMANSARI "Actually I have to create jsp file should be inside the view/hello folder" - Correct. That is the path I described in the answer above. I used `grails-app/views/hello/index.gsp` but `grails-app/views/hello/index.jsp` would work as well. I used GSP in the example because the question didn't indicate that you were are using JSP and GSP is by far more common in a Grails app. – Jeff Scott Brown Sep 19 '16 at 13:51
  • You said `view/hello` but that should be `views/hello`. – Jeff Scott Brown Sep 19 '16 at 13:52
0

Before accessing hello page you should generate views. "grails generate-views hello" try this way. I think adding jsp file is not the correct way.