- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我为每个模块(项目、产品……)使用相同的代码来导出 PDF。所有地方都工作正常,但在一个地方,PDF文件创建和下载成功,但在控制台中它给出了这样的错误。
getOutputStream() has already been called for this response. Stacktrace follows:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at grails.converters.JSON.value(JSON.java:199)
at grails.converters.JSON.render(JSON.java:134)
at grails.converters.JSON.render(JSON.java:150)
at com.****.***.RoomController$_closure2.doCall(RoomController.groovy:78)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:117)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:233)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:197)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:171)
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:722)
2013-05-06 17:38:54,381 ERROR [http-bio-8080-exec-5] GrailsExceptionResolver IllegalStateException occurred when processing request: [GET] /****/room/listByCompanyJSON - parameters:
extension: pdf
format: pdf
package com.company.pro
import grails.converters.JSON
import grails.plugins.springsecurity.Secured
import java.sql.Timestamp
import com.company.pro.constants.CommonSearchParams
import com.company.pro.constants.TicketType
import com.company.pro.decorator.JQGridDecorator
import com.company.pro.search.RoomSearch
class RoomController extends BaseController
{
def debugOn = log.isDebugEnabled()
static defaultAction = "list"
def userService
def inventoryJMSService
def filterUtilService
def accountJMSService
def ticketingJMSService
def minutesUntilStale = 5 //TODO: make this configurable?
def millisUntilStale = minutesUntilStale * 60 * 1000
def proExportService
@Secured(['ROLE_TelePresenceReportUser'])
def list(){
def colNames="'${g.message( code:'common.status' )}','${g.message( code:'rooms.label' )}','${g.message( code:'user.details.site' )}','${g.message( code:'device.city' )}','${g.message( code:'common.stateProvince' )}','${g.message( code:'common.country' )}'"
def colModel="{name:'status', editable: false, fixed: true, width:'60px'},{name:'room', editable: false, fixed: false, width:'200px'},{name:'siteName', editable: false, fixed: false, width:'350px'},{name:'city', editable: false, fixed:true, width:'125px'},{name:'state', editable: false, fixed: true, width:'150px'},{name:'country', editable: false, fixed: true, width:'150px'}"
[colNames:colNames, colModel:colModel]
}
@Secured(['ROLE_TelePresenceReportUser'])
def listJSON = {
chain(action: 'listByCompanyJSON', params: params)
}
@Secured(['ROLE_TelePresenceReportUser'])
def listByCompanyJSON = {
params.companyId= filterUtilService.getCurrentCustomer()?.id
params.monitoringStatus = CommonSearchParams.MONITORING
if(params.format!=null && params.format != "html"){
downloadList(session, params)
}
session.setAttribute("lastSearchParams", params)
def findRoomsResponse = inventoryJMSService.findRooms(params)
def search = new RoomSearch()
search.params = params
search.doSearch()
session.setAttribute("lastRoomsSearch", search.data?.collect {it.room})
def decorator = new JQGridDecorator(search)
def data = decorator.asRoomsListGrid()
def up = message(code:"status.up")
def down = message(code:"status.down")
data.rows.each {row -> row.cell[0] = row.cell[0] ? up : down }
render data as JSON
}
private downloadList(javax.servlet.http.HttpSession session, Map params) {
String cname = filterUtilService.getCurrentCustomer()?.name
cname = cname.replaceAll(" ","_")
def arrRooms =session.getAttribute("lastRoomsSearch")
def deviceArray = getAllDevices().findAll { device -> arrRooms.find({currRoom -> device.room == currRoom})}
def siteMap = getSiteMap(deviceArray)
deviceArray.each( {
it.siteName = it.siteName?.split(":")[1];
})
//populate device array with site map
deviceArray.each( {
it.metaClass.city = siteMap[it.siteId]?.city
it.metaClass.state = siteMap[it.siteId]?.state
it.metaClass.country = siteMap[it.siteId]?.country
it.metaClass.countryAbbrev = siteMap[it.siteId]?.countryAbbrev
it.metaClass.companyId = siteMap[it.siteId]?.companyId
it.metaClass.companyName = siteMap[it.siteId]?.companyName
})
def idList = deviceArray.collect({ it.deviceId})
def arrId = idList.toArray(new String[0])
//get url information for all device id's and populate that in deviceArray
params.deviceIds =arrId
params.populateSoldServices = false
def respo2 = inventoryJMSService.findDevicesByKeys(params)
def deviceByKeysSO = respo2.getDevices()
deviceArray.each({
def parentRec = it
def record = deviceByKeysSO.find {parentRec.deviceId == it.deviceHeaderMgmtSysSO.deviceId}
it.metaClass.deviceURL = record.deviceURL
it.metaClass.region = record.region
it.metaClass.floor = record.floor
})
List fields = ["city","state","companyId","companyName","countryAbbrev","country",
"productCategorization.tier1","productCategorization.tier2","productCategorization.tier3",
"deviceId", "deviceName","siteId", "siteName",
"mgmtSysAddIPSO.description","mgmtSysAddIPSO.ipAddress",
"mgmtSysAddIPSO.deviceExternalSysRefKey","mgmtSysAddIPSO.ipAddressTypeId",
"deviceURL",
"productCategorization.manufacturer","productCategorization.productModelVersion",
"region","floor","room"
]
Map labels = ["city" : message(code:"device.city"),
"state" : message(code:"common.stateProvince"),
"companyId" : message(code:"reports.telepresence.cdr.columns.COMPANYID"),
"companyName": message(code:"reports.telepresence.cdr.columns.COMPANYNAME"),
"countryAbbrev" : message(code:"common.country.abbrev"),
"country":message(code:"common.country"),
"deviceId": message(code:"device.label.id"),
"deviceName": message(code:"device.label.name"),
"siteId": message(code:"common.siteId"),
"siteName": message(code:"site.name"),
"deviceURL" : message(code:"device.url"),
"productCategorization.manufacturer": message(code:"device.detail.manufacturer"),
"productCategorization.productModelVersion": message(code:"device.detail.model.version"),
"region": message(code:"site.region"),
"floor":message(code:"site.floor"),
"room": message(code:"site.room")]
Map parameters
def title = message(code:"rooms.label.plural") + " " + message(code:"common.downloadDateTime") + " "+new Date()
if(params.extension == TicketType.EXPORT_EXCEL){
parameters = [title: title, "column.widths": [0.1, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.3, 0.3, 0.3,0.3,0.3,0.3,0.3,0.3,0.3, 0.2, 0.2, 0.2,0.2,0.2]]
labels << ["productCategorization.tier1": message(code:"device.product.categorization.tier1"),
"productCategorization.tier2": message(code:"device.product.categorization.tier2"),
"productCategorization.tier3": message(code:"device.product.categorization.tier3"),
"mgmtSysAddIPSO.description": message(code:"device.mgmt.system"),
"mgmtSysAddIPSO.ipAddress": message(code:"device.mgmt.system.address"),
"mgmtSysAddIPSO.deviceExternalSysRefKey": message(code:"device.mgmt.system.refc"),
"mgmtSysAddIPSO.ipAddressTypeId": message(code:"device.mgmt.system.ipAddress.typid")]
} else{
parameters = [title: title]
labels << ["productCategorization.tier1": message(code:"device.product.categorization.pc.tier1"),
"productCategorization.tier2": message(code:"device.product.categorization.pc.tier2"),
"productCategorization.tier3": message(code:"device.product.categorization.pc.tier3"),
"mgmtSysAddIPSO.description": message(code:"device.mgmt.sys"),
"mgmtSysAddIPSO.ipAddress": message(code:"device.mgmt.sys.address"),
"mgmtSysAddIPSO.deviceExternalSysRefKey": message(code:"device.mgmt.sys.refc"),
"mgmtSysAddIPSO.ipAddressTypeId": message(code:"device.mgmt.sys.ipAddress.typid")]
}
downloadDataToFiles(params.format, params.extension, "Room_List_" + cname,deviceArray, fields, labels, null, parameters)
return
}
/**
* This behavior has been moved to the JQGridDecorator object.
* Must remove this later, when there is time to test thoroughly
*/
private formatPanelResults={ findRoomsResponse ->
session.setAttribute("lastRoomsSearch", findRoomsResponse?.collect {it.room})
def allRows = findRoomsResponse?.collect {
[
cell: [
it.status,
it.room,
it.siteName,
it.city,
it.state,
it.country
],
id : it.room
]
}.unique()
def totalRows = allRows.size()
def maxRows = Integer.valueOf(params.rows?:1)
def currentPage = Integer.valueOf(params.page?:1)
def numberOfPages = Math.ceil(totalRows / maxRows).toInteger()
def rowOffset = ((currentPage - 1) * maxRows)
def maxIndex = rowOffset + maxRows
if (maxIndex > totalRows ) { maxIndex = totalRows }
[rows:allRows, records: totalRows, page: currentPage, total:numberOfPages]
}
@Secured(['ROLE_TelePresenceReportUser'])
def listDevicesByRoomJSON() {
if (params.room == null) {render ''}
def devicesForRoom = getRoomDeviceList().findAll { it.room == params.room }
if (debugOn) log.debug('devicesForRoom: ' + devicesForRoom)
def totalRows = devicesForRoom.size()
def maxRows = Integer.valueOf(params.rows?:1)
def currentPage = Integer.valueOf(params.page?:1)
def numberOfPages = Math.ceil(totalRows / maxRows).toInteger()
def rowOffset = ((currentPage - 1) * maxRows)
def maxIndex = rowOffset + maxRows
if (maxIndex > totalRows ) {maxIndex = totalRows}
if (debugOn) log.debug ("totalRows: $totalRows, maxRows: $maxRows, currentPage: $currentPage, numberOfPages: $numberOfPages, rowOffset: $rowOffset, maxIndex: $maxIndex")
def roleArr = session.getAttribute("roles")
def svcRole = roleArr.findAll{ it.name.equalsIgnoreCase('RequestServiceUser')}
def validRoleExists = false
if(svcRole.size == 1)
validRoleExists = true
def rows = devicesForRoom[rowOffset ..< maxIndex].collect() {
[
cell: [
it.deviceId,
it.deviceName,
it.status?'Up':'Down',
"<a href=" + createLink(controller:'requestService', action:'create',absolute:true, params:[thisDevice:it.deviceId, requestType:14, showDevSel:false]) + ">" + message(code:'default.button.create.label') + "</href>"
],
id:it.deviceId
]
}
def jsonData = [rows:rows, records: totalRows, page: currentPage, total:numberOfPages,showSvcReq:validRoleExists]
render jsonData as JSON
}
private uniqueRoomData() {
def deviceList = getRoomDeviceList()
def downRooms = deviceList.findAll { !it.status }.collect { it.room }
if (debugOn) log.debug("downRooms: $downRooms")
/* Added the below code for Download functionality */
//for the room list, we do not want device data
def temp = deviceList?.collect {
[
'status' : downRooms.contains(it.room) ? 'Down' : 'Up' ,
'room' : it.room,
'siteName' : it.siteName,
'city' : it.city,
'state' : it.state,
'country' : it.country
]
}
temp = sortList(temp)
//if more than one device in a room, there will be duplicate data. Remove it.
def rows = temp.unique().collect {
[
cell: [
it.status,
it.room,
it.siteName,
it.city,
it.state,
it.country
],
id : it.room
]
}
}
private sortList(list) {
def asc = params['sord']=='asc'
def idx = params['sidx']
if (asc) {
return list.sort { a, b ->
a[idx].compareToIgnoreCase(b[idx])
}
}
else {
return list.sort { a, b ->
b[idx].compareToIgnoreCase(a[idx])
}
}
}
private getRoomDeviceList() {
def roomDeviceList = session.getAttribute("roomDeviceList")
def roomDeviceListCreated = session.getAttribute("roomDeviceListCreated")
def refreshNeeded = false
//check for null or stale list
if (roomDeviceList != null && roomDeviceListCreated != null) {
def now = new Timestamp(System.currentTimeMillis())
refreshNeeded = (now - roomDeviceListCreated > millisUntilStale)
}
else {
//roomDeviceList or roomDeviceListCreated *is* null, generate new list
refreshNeeded = true
}
if(debugOn) log.debug( "refreshNeeded: " + refreshNeeded)
if (refreshNeeded) roomDeviceList = populateRoomDeviceListForSession()
if(debugOn) log.debug('roomDeviceList: ' + roomDeviceList?:"<null>")
return roomDeviceList
}
private populateRoomDeviceListForSession() {
//def devices = devicesInRooms(getAllDevices())
def devices = getAllDevices().findAll { it.room }
def alarmMap = getAlarmMap()
def siteMap = getSiteMap (devices)
def results = devices?.collect {
[
room : it.room,
deviceId : it.deviceId,
deviceName : it.deviceName,
siteName : it.siteName == null ? null: it.siteName.substring(it.siteName.indexOf(":")+1), //strip companyId & ':' from site name,
city : siteMap[it.siteId].city,
state : siteMap[it.siteId].state,
country : siteMap[it.siteId].country,
status:!(alarmMap?.values()?.contains(it.deviceId))
//status: message(code:alarmMap.values().contains(it.deviceId)?'status.down':'status.up')
]
}
session.setAttribute("roomDeviceList", results)
session.setAttribute("roomDeviceListCreated",new Timestamp(System.currentTimeMillis()))
return results
}
private getAllDevices() {
//AuthenticatedUser usr = springSecurityService.getPrincipal()
params.companyId= filterUtilService.getCurrentCustomer()?.id //usr.getCompanyId()
params.totalDeviceCountNeeded=true
params.monitoringStatus = CommonSearchParams.MONITORING
def tempRowParam = params.rows //need to store this value - will restore it later
params.rows = 9999 //we need all devices to find those with rooms...
def resp = inventoryJMSService.searchDevices(params)
params.rows = tempRowParam //restore original value so that pagination will work properly on first call
log.info("getAllDevices params:$params")
return resp?.getSearchDevices()
}
private getSiteMap(devices) {
String[] siteIds = (devices*.siteId).unique()
def siteMap = [:]
if (!siteIds) {
return siteMap
}
def resp = accountJMSService.findSitesByKeys([siteIds:siteIds])
resp?.sites?.each {
siteMap.put(it.id, [
name: it.name == null ? null: it.name.substring(it.name.indexOf(":")+1), //strip companyId & ':' from site name,
city:it.city,
state:it.stateProvince,
//country:it.countryAbbrev,//updated
countryAbbrev:it.countryAbbrev,
country:it.country,
companyId: it.companyId,
companyName:it.companyName
]
)
}
if (debugOn) log.debug(siteMap)
return siteMap
}
private getAlarmMap() {
def tempRowParam = params.rows //need to store this value - will restore it later
params.rows = 9999
if (debugOn) log.debug("getAlarmMap params: $params")
def resp = ticketingJMSService.searchAlapro([companyId:params.companyId, monitoringStatus:CommonSearchParams.MONITORING, ticketState: 'OPEN'])
def map = [:]
params.rows = tempRowParam //restore original value so that pagination will work properly on first call
log.info("getAlarmMap params:$params")
resp?.alapro?.each {
map.put(it.id, it.deviceId)
}
if (debugOn) log.debug("getAlarmMap map: $map")
return map
}
def listAll = {
def customer = filterUtilService.getCurrentCustomer()?.id
def search = new RoomSearch(customer)
render search.parseDataAsJSON() as JSON
}
def lastSearchFullDataset = {
def params = session.getAttribute("lastSearchParams");
params.loadonce = true
def search = new RoomSearch()
search.params = params
search.doSearch()
render search.data as JSON
}
def getRoomsByGroup = {
def rooms = []
def group = params.group=='Group 1'?'0':'1'
getAllDevices().collect{
if(group == it.group){
if(it.room !=null && it.room.trim() !="" && it.room.trim().length()>0){
rooms.add(it.room)
}
}
}
render rooms as JSON
}
}
最佳答案
当您直接渲染事物时,让 grails 知道不要渲染 View 。采用:
//outputStream - make sure you close it
OutputStream out
try {
out = response.getOutputStream()
out << bytes
} catch (IOException ioe) {
//gulp - can't send to the browser
} finally {
try {
out?.close()
} catch (IOException ioe) {
//gulp - can't close
}
}
//or render input stream
render ( file: <InputStream>, contentType: '<content/type>')
//or render byte array
render ( file: <byte[]>, contentType: '<content/type>')
//or just tell Grails that you don't want the view rendered.
GrailsWebRequest webRequest =
(GrailsWebRequest) RequestContextHolder.currentRequestAttributes()
webRequest.setRenderView(false)
关于Grails Export : getOutputStream() has already been called for this response. Stacktrace 如下:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16400625/
我希望这个问题能够在 SO 的规则下存活下来,因为我进行了很多搜索,没有找到关于它的文档,有时甚至忽略了它,但这让我既不理解问题也不理解解决方案。 Exceptoion 的 StackeTrace 有
我正在Gradle项目中设置Spotbugs,但是当我运行它时,Spotbugs会生成输出报告,但是将失败的堆栈跟踪记录到控制台。我想知道是否有办法抑制它。 这是我的Gradle文件: buildsc
这是我执行类的主要方法的任务,该类在Java项目的build.gradle中定义: task(runClass, type: JavaExec) { try { main =
我遇到了一个意外错误,它创建了包含大量行和不同库的 stackTrace。如果从上到下阅读,可以看到除了第2-3个方法之外的每个被调用的方法。看起来像 //Pseudo code method1_1(
我正在尝试将 gradle java 应用程序部署到 heroku (基于 jhipster)。我可以使用“heroku local”在本地构建并运行它,但是当我尝试远程部署它时,当它尝试构建应用程序
以下异常: Exception in thread "main" java.lang.NullPointerException at javaapplication7.App.main(App.jav
我需要按关键字从日志文件中 grep 完整的堆栈跟踪。 这段代码工作正常,但在大文件上会变慢(比文件更慢)。 我认为改进正则表达式以查找关键字的最佳方法,但我无法完成。 #!/usr/bin/perl
我在托管应用程序中收到错误消息,我正在尝试了解错误发生的原因。 为此,我查看了错误页面上的堆栈跟踪,如下所示: [ NullReferenceException: Object reference n
我的日志库中有这段代码 var stackTrace = new StackTrace(); string operationName = stackTrace.GetFrame(1).GetMeth
我们正在运行多个 Sitecore 网站,并且刚刚收到反馈,在出现错误时向网站用户提供堆栈跟踪可能很危险。既然人们获得了堆栈跟踪信息,该网站是否会更容易受到黑客攻击? 最佳答案 这绝对是弊大于利。根据
我们正在使用 Rational Application Developer 7.5(基于 Eclipse 3.4)为 WebSphere Application Server 6.1 开发一个 Web
给定以下流畅的 API 调用: Foo() .Bar1(() => { ... }) .Bar2(() => { ... }) .Bar3(); 我想稍后确定代码文件和 Bar
在我使用 StackTrace 的代码中发生了一些奇怪的事情。几乎就像没有加载调试信息一样......但我正在 DEBUG 构建上运行它。.pdb 文件肯定在 bin 目录中并且是最新的。我的想法真的
我不断收到此错误,我似乎在网上找不到任何帮助。我是flutter和android studio的新手。非常感谢任何帮助 FAILURE:构建失败并出现异常。 Where: Build file 'C:
在我的项目的目标目录中,有一个名为 stacktrace.log 的文件。我已经意识到文件的大小已经超过 3 GB。删除这个文件对我来说安全吗?删除后是否会导致任何文件未找到异常?谢谢你的时间。 -
我知道 http://richhickey.github.com/clojure/clojure.stacktrace-api.html . 有没有办法在不抛出异常并捕获它的情况下获取当前的堆栈跟踪?
我有一个异常记录器,它将所有异常记录到日志文件中: class function TLogger.LogException (ACaller: String; E: Exception): Boole
有时我在jQuery UI js文件的一行中收到错误或未处理的异常。我知道问题是一个空或空的对象或属性传递给jQuery。例如,在Chrome浏览器中,我收到“未捕获的TypeError”错误。 做一
我只是通过使用全局函数(在我的情况下称为GetCallingMethod)进行了一些分析。 通常情况下,它的效果很好。但是在某些情况下,应用程序被阻止。当关闭应用程序时,它被阻止。在Visual St
我正在分析遗留应用程序中的错误,同时清理并改进它。我有一些堆栈跟踪被记录到数据库中,但是它存储的量有一个限制 (VARCHAR2(1000)),并且错误发生在 System.Data 的深处.....
我是一名优秀的程序员,十分优秀!