我正在使用带有Grails 2.3.8的exporter plugin 1.6,这是我的控制器列表方法:
def list () {
println "*** List method called."
println "*** Params: " + params
if(!params.max) params.max = 10
if(params?.exportFormat && params.exportFormat != "html"){
response.contentType = grailsApplication.config.grails.mime.types[params.exportFormat]
response.setHeader("Content-disposition", "attachment; filename=chairs.${params.extension}")
List fields = ["constructionMaterials"]
Map labels = ["constructionMaterials": "Construction Materials"]
// Formatter closure
def upperCase = { domain, value ->
return value.toUpperCase()
}
Map formatters = [constructionMaterials: upperCase]
Map parameters = [constructionMaterials: "Cool Chairs", "column.widths": [0.2, 0.3, 0.5]]
println "*** Does it make it here?"
exportService.export(params.exportFormat, response.outputStream,Chair.list(params), fields, labels, formatters, parameters)
}
[ chairInstanceList: Chair.list( params ) ]
}
单击CSV和XML时工作正常但是当我点击PDF时出现此错误。
| Error 2014-06-26 01:47:49,139 [http-bio-8080-exec-8] ERROR [/demoApp].[default] - Servlet.service() for servlet [default] in context with path [/demoApp] threw exception [org.springframework.web.util.NestedServletException: Request processing failed; nested exception is groovy.lang.MissingMethodException: No signature of method: static java.lang.Math.max() is applicable for argument types: (java.lang.Integer, null) values: [4, null]
Possible solutions: max(int, int), max(double, double), max(float, float), max(long, long), min(int, int), wait()] with root cause
Message: No signature of method: static java.lang.Math.max() is applicable for argument types: (java.lang.Integer, null) values: [4, null]
Possible solutions: max(int, int), max(double, double), max(float, float), max(long, long), min(int, int), wait()
Line | Method
->> 251 | doAppend in org.apache.log4j.AppenderSkeleton
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 66 | appendLoopOnAppenders in org.apache.log4j.helpers.AppenderAttachableImpl
| 206 | callAppenders . . . . in org.apache.log4j.Category
| 391 | forcedLog in ''
| 856 | log . . . . . . . . . in ''
| 192 | logMessage in org.slf4j.impl.GrailsLog4jLoggerAdapter
| 167 | error . . . . . . . . in ''
| 213 | error in org.apache.commons.logging.impl.SLF4JLog
| 198 | doFilter . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . . . . . . . in java.lang.Thread
为什么它会导出两种格式,但在PDF上出错?
更新:好的,这很奇怪,但我认为当我有超过4个域实例时,PDF选项最终会起作用。当数字等于或低于该数字时。谁能解释一下?当它最终工作时this是我得到的文件。 this是我得到的等效XML文件。