报错目录
- 1、Mapper method 'com.xxx' has an unsupported return type: class xxx.object
- 2、Failed to decode downloaded font
- 3、Uncaught TypeError: Cannot read property 'xx' of null
- 4、Parameter 'xx' not found. Available parameters are [0, 1, param1, param2]
- 5、No qualifying bean of type [com.*.*.*]
- 6、Uncaught RangeError: Maximum call stack size exceeded.
- 7、A query was run and no Result Maps were found for the Mapped Statement 'com.xx'. It's likely that neither a Result Type nor a Result Map was specified.
- 8、There is no getter property of "xxx"
- 9、Invalid bound statement (not found)
- 10、Initializing Java Tooling has encountered a problem
- 11、服务器没有返回数据
- 12、ajax中出现部分数据为`undefined`
- 13、Uncaught TypeError: Cannot read property 'length' of undefined
- 14、如果插入数据混乱
- 15、Unknown column 'a.salverid' in 'where clause'
- 16、Cannot read property 'length' of undefined
1、Mapper method ‘com.xxx’ has an unsupported return type: class xxx.object
- 报这个错一般都是返回的数据和你在mybatis设置的返回值冲突,找到相应SQL看看mybatis设置的返回值和你方法的返回值是否对应
2、Failed to decode downloaded font
3、Uncaught TypeError: Cannot read property ‘xx’ of null
4、Parameter ‘xx’ not found. Available parameters are [0, 1, param1, param2]
方法一:
**Mapping.xml
select * from login where name=#{0} and password=#{1}
把参数修改为下标
方法二:
**Dao.java
public Login **(@param("name")String username,@param("pwd")String password);
添加
@Param
注解, name、pwd 是别名对应**Mapping.xml里面的select * from login where name=#{name} and password=#{pwd}
定义别名
5、No qualifying bean of type [com...*]
- 添加serviceImpl扫描的路径
<context:component-scan base-package="cn.appsys.service"/>
<context:component-scan base-package="cn.appsys.serviceImpl"/>
<context:component-scan base-package="cn.appsys.dao"/>
- 把现实类和服务接口放在一个包下统一扫描。
Service - IUserService.java
impl - UserServiceImpl.java
- 在实现类中加上注解
@Service("user")
public class UserServiceImpl implements IUserService{ ... }
6、Uncaught RangeError: Maximum call stack size exceeded.
- 可能是获取值时,没有加val()
var floor = $("#floor").val();
$.post( '',{ registerName: $('#regName') } )
//代替:
$.post( '',{ registerName: $('#regName').val() } )
- 执行递归运算时,没有加判断条件,出现死循环。使得调用堆栈不断增长,达到一个限制时,内存耗尽,栈溢出
- 例如将大以百多万条目内容,转换成字符串,会因为条目太大而无法放入堆栈中。
String.fromCharCode.apply(null, new Uint16Array(bytes))
- 解决:必须放在一个for循环中分开调用,而不是一次调用中执行此操作。
var uintArray = new Uint16Array(bytes);
var converted = [];
uintArray.forEach(function(byte) {
converted.push(String.fromCharCode(byte))
});
- 如果由于某种原因需要运行无限进程/递归,则可以在单独的线程中使用webworker。
7、A query was run and no Result Maps were found for the Mapped Statement ‘com.xx’. It’s likely that neither a Result Type nor a Result Map was specified.
已运行查询,但找不到映射语句“com.xx”的结果映射。很可能既没有指定结果类型,也没有指定结果映射。
例如:
- 需要在该
.xml
映射文件中的该条语句修改resultMap
属性 - 属性
resultMapp
和resuleMap
结果集中的id一致
<mapper namespace="com.xxxMapper">
<resultMap id="BaseResultMap" type="com.xxx">
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="class " property="class " jdbcType="VARCHAR" />
</resultMap>
<select id="selectByPrimaryKeySelective" resultMap="BaseResultMap" parameterType="java.lang.String">
select id,name,class from xxx where class='xx' and id={#x,,jdbcType=VARCHAR} order by desc
</select>
</mapper>
8、There is no getter property of “xxx”
不能获取(getter)属性xxx
-
可以查看配置文件和实体类之间映射关系,
如果存在映射到另一张表,则也需要将这个表的类型和属性写进实体类中 -
查看该属性名称是否与实体类匹配,或者是否有
get
方法
resolveid = #{Resolvied,jdbcType=INTEGER},
private Integer Resolveid; //#{} 之中获取的变量与POJO中不匹配报错
9、Invalid bound statement (not found)
绑定语句无效(未找到),就是接口与xml要么是找不到,要么是找到了却匹配不到。
- dao接口与xml的文件名不一致。 接口名与Mybatis的映射文件名一定要一模一样;
- SQL 的 id 名与 Dao 层中的函数名是否一致,检查方法名称是否对应;
- 检查xml文件所在package名称是否和Mapper interface所在的包名一一对应;
- 检查xml的namespace是否和xml文件的package名称一一对应;
- 去除xml文件中的中文注释;
- 随意在xml文件中加一个空格或者空行然后保存。
10、Initializing Java Tooling has encountered a problem
-
删除工作空间\workspace.metadata.plugins\org.eclipse.core.resources.projects的文件
来源:百度百科
-
进入eclipse的安装目录,命令行运行一下eclipsec.exe即可
这样运行的Eclipse如果你不小心关闭了命令行,那么Eclipse也会随之关闭。
来源:博客园
-
不要删除完整的 .metadata
- 备份
.metadata
- 只删除
.metadata/.plugins/org.eclipse.core.resources/.project
- 重启 eclipse
- 查看项目创建文件夹
- 如果你使用的代码仓库是
SVN
、Git
、HG
,直接删除 - 关闭 eclipse
- 备份相关项目与当前项目合并
.metadata/.plugins/org.eclipse.core.resources/.project
- 重启 eclipse
来源:栈溢出
- 备份
11、服务器没有返回数据
可能是ajax请求的url路径写错
12、ajax中出现部分数据为undefined
- 如果使用ajax出现部分数据显示undefined,请查看前端页面返回数据中变量是否正确。其变量名应该与映射文件中的property中的属性名一致,即可Java实体类POJO中的属性名一致。
13、Uncaught TypeError: Cannot read property ‘length’ of undefined
14、如果插入数据混乱
1. 如果遇到插入到数据库的数据混乱,请查看提交的Ajax变量获取和提交是否正确
2.
3.
function insert() {
var sid = $("#sid").val();
var sNum = $("div[class*='selected']").attr("value");
var scode = document.getElementById("pmgg").value.split("/")[0];
var sRule = document.getElementById("sRule").value;
$.ajax({
url : "../rfCollection/insert.action",
type : "post",
data : {
sid : sid,
sNum : sNum,
scode : scode,
sRule : sRule
},
async : false,
dataType : "json",
error : function() {
alert("服务器没有返回数据");
},
success : function(msg) {
alert(msg);
}
});
}
15、Unknown column ‘a.salverid’ in ‘where clause’
可能是前面没有别名而后面利用了别名来操作
<update id="updateUserNum" parameterType="com.kckj.pojo.User">
update user
set num= #{num,jdbcType=VARCHAR},
where a.salverid=#{salverid};
</update>
16、Cannot read property ‘length’ of undefined
- json格式错误
要把json字符串转换为json对象
success : function(obj) {
json = obj.jsonSalverid; //从后台控制器获取的来自XML的返回数据,
var index = 0; //遍历index
var list = $("div[class^='Contenter']").children()[0];
list = $(list).find("div")[0];
list = $(list).find("div");//获取原有数组
var spaceSize = list.length; //获取原有长度
fnSame(json[0].goodsarea); //取出googdsarea,调用fnSame
$.each(date, function(i, item) {
var locAreaCode = item.locAreaCode;
if(!isNaN(locAreaCode) && locAreaCode % 10 + 10000 == locAreaCode) {
locAreaCode=locAreaCode%10;
}else if(!isNaN(locAreaCode) && locAreaCode % 100 + 10000 == locAreaCode) {
locAreaCode=locAreaCode%100;
}else if(!isNaN(locAreaCode) && locAreaCode % 1000 + 10000 == locAreaCode) {
locAreaCode=locAreaCode%1000;
}else if(!isNaN(locAreaCode) && locAreaCode % 10000 + 10000 == locAreaCode) {
locAreaCode=locAreaCode%10000;
}
if(list.length<=index){ //长度不够则创建
$("<div class='locList' style='"+$($(list)[0]).attr("style")+"'>区域"+locAreaCode+"</div>").appendTo(list[0].parentNode);
}
$(list[index]).text("区域" + locAreaCode); //设置文本内容
$(list[index]).attr("value","CN"+locAreaCode); //获取ss_number
$(".locName").text($(list).find("div[class*=' selected ']").text());
$(".locName").attr("value",$("div[class*='selected']").attr("value"));
index = index+1; //因为外面还需要 所以不能++
}); //each End
if(list.length>index){ //如果长度过多,则移除多余部分
for (var i=0;i<list.length-index;i++){
$($(list)[list.length-1-i]).remove();//移除多余的
}
}
changeLine();
}
@Resource private IResViewService resViewService;
@ResponseBody
@RequestMapping(value = "/queryInfoUL", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public List<ResCollection> queryUserLine(HttpServletRequest request,
HttpServletResponse response)throws IOException {
response.setContentType("text/html;charset=UTF-8"); //将请求内容编码设置为UTF-8,如果没有设置需要自己在JS中解析,所以干脆自己直接提前设置了
PrintWriter writer=response.getWriter(); //字符串输出流
JSONObject obj = new JSONObject(); //JSON对象,数据传输对象,常被用作Ajax异步请求的返回对象使用
List<ResView> queryLineCode = this.resViewService.queryByUserLine();
obj.put("jsonUL", queryLineCode); //"key":value key必须是字符串,value则是从xml映射文件中返回的数据
writer.print(obj); //写入JSON对象
writer.flush(); //刷新
return null;
}
- 出现这种现象的原因:
变量s为字符类型时,s=null的时候,当用var len = s.length,就会报上面的错误
解决方法:判断s为null的时候( if | 三目都可以),将s改成:
s='item.money==null?"":item.money';
待续 ...