【问题标题】:Error initializing GroovyPageView初始化 GroovyPageView 时出错
【发布时间】:2014-01-31 13:53:44
【问题描述】:

我正在使用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"
    }

}

这就是我的文件夹结构:

【问题讨论】:

  • 检查 angular.js 是否正确加载。估计js加载有问题。
  • 你有在 ApplicationResources.groovy 中定义的角度模块吗?对吗?
  • 并将 ApplicationResources 文件的内容放入您的问题中
  • @AramArabyan 请看我的更新!
  • 也试过了,但结果和以前一样......

标签: grails grails-2.0


【解决方案1】:

它说异常 在属性名称 (ng-app) 后需要 '='。 为什么将“ng-app”放在“head”标签中? 尝试删除它。

【讨论】:

  • 感谢您的回答!但是,将它放入我的&lt;div&gt; 不会使用 angularjs。我只是得到普通的html output,它不是由angularjs 呈现的。
  • 尝试将 ng-app 放到你的 html 标签中。
猜你喜欢
  • 2016-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-02
  • 2019-02-02
  • 1970-01-01
相关资源
最近更新 更多