【发布时间】:2015-07-17 19:11:19
【问题描述】:
我已经完成的步骤:
- 创建新项目
- 将
mavenRepo "http://repo.grails.org/grails/core"添加到 BuildConfig.groovy 中的存储库 - 在 BuildConfig.groovy 的插件中添加
compile ":easygrid:1.7.1" - 使用
String firstname和String lastname添加域类com.test.Author - 用
def index() { }添加控制器com.test.HomeController - 添加文件
views/home/index.gsp
接下来,我在 com.test.HomeController 中添加了以下内容:
def authorJQGrid = {
domainClass Author
gridImpl 'jqgrid'
jqgrid {
sortname 'firstname'
}
export {
export_title 'Author'
pdf {
'border.color' java.awt.Color.BLUE
}
}
columns {
firstname
lastname
}
}
我在 home/index.gsp 中添加了以下内容:
<!DOCTYPE html>
<html>
<head>
<asset:javascript src="easygrid.jqgrid.js"/>
<asset:stylesheet src="easygrid.jqgrid.css"/>
</head>
<body>
<grid:grid id='jqgridinitial' name='authorJQGrid'>
<grid:set width="900" caption="Authors"/>
</grid:grid>
<grid:exportButton name='authorJQGrid'/>
</body>
</html>
当我编译这个时,我看到以下错误:
Could not process the EasygridConfig file
当我尝试访问网页时,我收到以下错误:
[http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - 处理请求时发生 NullPointerException:[GET] /website/home/ 无法在空对象上获取属性“authorJQGrid”。堆栈跟踪如下: 消息:处理 GroovyPageView 时出错:执行标签时出错:无法在空对象上获取属性“authorJQGrid”
我该怎么做才能让 JQGrid 正常工作?
【问题讨论】:
-
您是否使用 @Easygrid 注释了您的 Controller 类?
-
那是我的问题。谢谢!