包如下的錯:java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
1.在一個對象的屬性中使用@ManyToOne對于某一個關聯的字段時,在使用findAll會報如下的錯,如下圖是在一個對象中使用了@ManyToOne
但是findAll會報如下的錯,并且查詢時返回很多的字段和數據,但是有些不是你想要的,如下圖所示
springmvc注解,解決方法:
在查詢的時候,不返回@ManyToOne注解的這個字段即可解決這個錯,代碼如下
@RequestMapping(method = RequestMethod.GET)public Object listAllStreams(@RequestBody JSONObject param) {JSONObject result;try {List<Stream> streams = streamService.listAll(param);JSONArray jsonArray = new JSONArray();for(Stream stream:streams){JSONObject object = new JSONObject();object.fluentPut("name",stream.getName()).fluentPut("fields",stream.getFields()).fluentPut("from", stream.getFrom()).fluentPut("groupBy",stream.getGroupBy()).fluentPut("identifier",stream.getIdentifier()).fluentPut("keyBy",stream.getKeyBy()).fluentPut("solution",stream.getSolution());jsonArray.add(object);}result = onSuccess(streams);} catch (Exception e) {log.error("{query all stream failed, reason : {}}", e);String error = e.getMessage();result = onFail(error);}return result;}
?
最后返回的結果與預期一樣。這是個人的經驗總結,如有更好歡迎討論。
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态