In Grails 2.x, the following works:
class UrlMappings {
static mappings = {
/**
* Serving the index.html directly
*/
"/"(uri: "/ng/app/index.html")
}
}
Given that there is a index.html
file available in web-app/ng/app/
directory. Now when we browse the URL http://localhost:8080
in Grails 2, the index.html
renders automatically.
In Grails 3, I added the same index.html
file in src/main/webapp/
, I can properly browse the same like http://localhost:8080/static/index.html
.
So, I'm trying to do the same in UrlMappings.groovy
:
class UrlMappings {
static mappings = {
/**
* Serving the index.html directly
*/
"/"(uri: "/static/index.html")
}
}
But this is giving me error {"message":"Internal server error","error":500}
:
ERROR org.grails.web.errors.GrailsExceptionResolver - UrlMappingException occurred when processing request: [GET] /
Unable to establish controller name to dispatch for [null]. Dynamic closure invocation returned null. Check your mapping file is correct, when assigning the controller name as a request parameter it cannot be an optional token!. Stacktrace follows:
grails.web.mapping.exceptions.UrlMappingException: Unable to establish controller name to dispatch for [null]. Dynamic closure invocation returned null. Check your mapping file is correct, when assigning the controller name as a request parameter it cannot be an optional token!
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I've create my app with Grails 3.1.8 Angular profile and later removed Angular related stuff like Grails GSP plugin, Asset pipeline etc.