【问题标题】:kotlin reture object throw java.lang.IllegalStateException: getOutputStream() has already been called for this responsekotlin reture object throw java.lang.IllegalStateException: getOutputStream() has already been called for this response
【发布时间】:2018-09-26 20:41:53
【问题描述】:

我想用 kotlin 的对象作为 dto

@ResponseBody
fun getBindCar(coachId: Long): List<Any> {
    val coach = coachRepository.findById(coachId).get()
    var result = mutableListOf<Any>()
    coach?.cars.forEach { it ->
        var o = object : Serializable {
            var id: Long = 0L
            var licenceNum = ""
        }
        o.id = it.id
        o.licenceNum = it.licenceNum
        result.add(o)
    }
    return result
}

返回时抛出异常

2018:04:106:18:35:36.936 [http-nio-8080-exec-4] 警告 oswsmmaExceptionHandlerExceptionResolver - 处理程序执行引起的已解决异常:java.lang.ClassCastException:org.appsugar.archetypes.web。 controller.oa.CoachController$getBindCar$1$o$1 不能转换为 org.springframework.core.io.support.ResourceRegion 在路径 []抛出异常[请求处理失败;嵌套异常是 java.lang.IllegalStateException: getOutputStream() 已经为此响应调用] 根本原因 java.lang.IllegalStateException: getOutputStream() 已为此响应调用

【问题讨论】:

    标签: servlets web kotlin


    【解决方案1】:

    当我将返回类型从 List&lt;Any&gt; 更新为 Any 时,它可以工作

    【讨论】:

      猜你喜欢
      • 2020-03-13
      • 2013-07-05
      • 1970-01-01
      • 2017-04-17
      • 2018-09-21
      • 2013-05-04
      • 2019-07-23
      • 1970-01-01
      相关资源
      最近更新 更多