数据库中存在int型的字段,但是初始值为null,mybatis取值之后就会报错, org.apache.ibatis.binding.BindingException: Mapper method 'getSort' (xx.yy.cc.DxxDAO) attempted to return null from a method with a primitive return type (int). 解决:采用了取巧的方式,将实体类对应的该字段设置成String类型,mybatis取出来之后自
在开发过程中,我们需要统一返回前端json格式的数据,但有些接口的返回值存在 null或者""这种没有意义的字段.以上不仅影响理解,还浪费带宽,这时我们可以统一做一下处理:不返回空字段,或者把NULL转成“”. 要做要以上,经过网上寻找资料,发现很多文章都是相互拷贝,于是从网上自己寻找资料,对他们进行整理,记录,同时可以对返回的null字段进行灵活配置. spring 内置的json处理框架是Jackson.我们可以对它配置一下达到目的,具体代码如下. @Configuration p
org.json.JSONObject orgJSON = new org.json.JSONObject(); // The method put(String, Collection) is ambiguous for the type JSONObject //orgJSON.put("null", null); net.sf.json.JSONObject netJSON = new net.sf.json.JSONObject(); netJSON.put("nul
再用MyBatis操作Oracle的时候,传入null值而引发的错误 异常信息: org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration pr