且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

初始化GroovyPageView时出错

更新时间:2022-10-15 08:09:32

它在异常
中表示在属性名称(ng-app) STRONG>。
为什么你把 ng-app 放在head标签中?
尝试删除它。

I am using grails 2.3.4. When I load my index.gsp page I get:

| Server running. Browse to http://localhost:8080/testApplication
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion:
....[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context w
ith path [/testApplication] threw exception
org.codehaus.groovy.grails.web.mapping.exceptions.UrlMappingException: Error map
ping onto view [/index]: Error initializing GroovyPageView
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: Error initializing GroovyPageView
        ... 3 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException:
Expecting '=' after attribute name (ng-app).
        ... 3 more
[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context with
path [/testApplication] threw exception
org.codehaus.groovy.grails.web.mapping.exceptions.UrlMappingException: Error map
ping onto view [/index]: Error initializing GroovyPageView
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: Error initializing GroovyPageView
        ... 3 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException:
Expecting '=' after attribute name (ng-app).
        ... 3 more
[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context with
path [/testApplication] threw exception
org.codehaus.groovy.grails.web.mapping.exceptions.UrlMappingException: Error map
ping onto view [/index]: Error initializing GroovyPageView
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: Error initializing GroovyPageView
        ... 3 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException:
Expecting '=' after attribute name (ng-app).
        ... 3 more

My index.gsp looks simple:

<head ng-app> 
<meta name="layout" content="main" />
<title>Title Page</title>

<!-- here we are loading angularjs -->
<r:require module="angular" />

</head>
<body>
    <div>
        <div>Hello World!</div>
        <p>Nothing here {{'yet' + '!'}}</p>
        <p>1 + 2 = {{ 1 + 2 }}</p>
    </div>
</body>

and my URL mapping looks like that:

class UrlMappings {

    static mappings = {
        "/api/product"(resources:"product")
        "/$controller/$action?/$id?(.${format})?"{
            constraints {
                // apply constraints here
            }
        }

        "/"(view:"/index")
        "500"(view:'/error')

    }
}

Why do I get this error? I really appreciate your answer!

UPDATE

My ApplicationResources.groovy file:

modules = {

    'angular' {
        resource url:'/js/lib/angular-1.2.8/angular.min.js'
        resource url:'/js/lib/angular-1.2.8/angular-resource.min.js'
        println "Loading libs"
    }

}

Thats my folder structure:

It says in exception Expecting '=' after attribute name (ng-app). Why you put "ng-app" in "head" tag ? try to remove it.