先码一个,try catch没有捕获到OutOFBoundsException
来源:互联网 发布:退火算法 matlab 编辑:程序博客网 时间:2024/06/07 16:44
源码:
public Integer findTypeById(String type) throws Exception { Integer page = null; System.out.println(type); NewsTypeExample newsTypeExample = new NewsTypeExample(); NewsTypeExample.Criteria criteria = newsTypeExample.createCriteria(); criteria.andTypeDirEqualTo(type); List<NewsType> types = newsTypeMapper.selectByExample(newsTypeExample); try { page = types.get(0).getTypeId(); } catch (IndexOutOfBoundsException e) { throw new CustomException("分类不存在。"); } return page;}
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0at java.util.ArrayList.rangeCheck(ArrayList.java:653)at java.util.ArrayList.get(ArrayList.java:429)at com.amoxu.service.impl.NewsServiceImpl.findTypeById(NewsServiceImpl.java:75)
期望的是交给CustomerException处理,系统交给全局的控制器处理了。
目前还有找到原因。
待续
好吧 修改文件之后要在maven里clean之后再运行
阅读全文
0 0
- 先码一个,try catch没有捕获到OutOFBoundsException
- try-catch一次只能捕获一个异常
- try catch捕获异常
- try{}catch{}异常捕获
- @try@catch捕获异常
- 捕获异常 try...catch{}
- try catch 捕获异常
- try catch 捕获异常
- java try没有catch
- 使用try/catch捕获异常
- 捕获异常的Try Catch
- thinkphp 捕获异常 try catch
- php try catch捕获错误
- 异常捕获try-catch-finally
- try catch多个catch捕获问题
- 记录一个try catch没有生效的原因,以便备忘
- vs开发,添加try catch(...)发现没有捕获异常,需要对编译命令进行设置
- 关于C++ try catch 不能捕获到SEH异常的问题
- Java(3-3)
- UVa 123|Searching Quickly|字符串处理
- 个人计划《2017-10-06》
- HYSBZ1941-Hide and Seek
- shell脚本语法
- 先码一个,try catch没有捕获到OutOFBoundsException
- DBSDFZOJ 模拟考试 命运 最小生成树+乱搞
- bat命令入门与高级技巧详解
- 160个练手CrackMe-004
- master -> master (non-fast-forward)和git ! [rejected] master -> master (fetch first)
- 前端之路——第七篇:整理目前疑问点/css必会伪类选择器/css媒体查询
- PAT 1025. 反转链表 (25)
- HDU
- MySQL 元数据