初始化GroovyPageView时出错

时间:2014-01-31 13:53:45

标签: grails grails-2.0

我正在使用grails 2.3.4。当我加载index.gsp页面时,我得到:

| 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

我的index.gsp看起来很简单:

<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>

我的URL mapping看起来像这样:

class UrlMappings {

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

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

    }
}

为什么会出现此错误? 我非常感谢你的回答!

更新

我的ApplicationResources.groovy文件:

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"
    }

}

这就是我的文件夹结构:

enter image description here

1 个答案:

答案 0 :(得分:1)

它在例外中说 在属性名称(ng-app)之后期待'='。 为什么要在“head”标签中加入“ ng-app ”? 试着删除它。

相关问题