Grails导出插件奇怪的行为,只在PDF上出错,其他则很好
我将1.6与Grails 2.3.8一起使用,这是我的控制器的列表方法:Grails导出插件奇怪的行为,只在PDF上出错,其他则很好,grails,Grails,我将1.6与Grails 2.3.8一起使用,这是我的控制器的列表方法: def list () { println "*** List method called." println "*** Params: " + params if(!params.max) params.max = 10 if(params?.exportFormat && params.exportFormat != "html"){ response.
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选项最终会起作用。当该数字等于或低于该数字时,则不适用。有人能解释一下吗?当它最终起作用时,我得到的是文件。并且是我得到的等效XML文件