1. 数据库索引的作用及其索引原理
作用:提高查询效率 全表扫描
索引原理:采用某种数据结构存储索引,二叉树、平衡树、Hash表、BTree、B+Tree
主键索引(聚集索引)、唯一索引、联合索引、普通索引
create unique index 索引名(字段)
2. Eunumeration和Iterator接口的区别?
共同:都是接口,都可以对集合进行迭代
不同:Enumeration一般对Hashtable和Vector这种安全类型的集合进行迭代
Iterator可以对实现了Collection接口的集合进行迭代
Iterator支持fail-fast(Concurrent Modification Exception)
推荐使用Iterator
3. SQL语句的执行顺序
select 字段 from 表1 join 表2 on 链表条件 where 筛选条件 group by 分组字段 having 分组过滤 order by 排序字段 limit xxx
- from:得到一个虚拟表v1
- join之后的带一个笛卡尔表v2
- on 对v2表中的数据进行过滤 v3
- where 对v3中的数据进行筛选 v4
- select选择v4表中的对应字段 v5
- group by 对v5进行分组 v6
- having 对v6进行筛选 v7
- order by 对v7进行排序 v8
- limit 对v8进行限制 v9
4. 事务在什么时候会失效
A-》B
- 抛出了检测异常
- trycatch处理了
5. 什么是Spring的Bean循环依赖,如何解决?
A->B->A
<bean id="a" class="A">
<property name="b" ref=“b”>
</bean>
<bean id=“b” class="B">
<property name="a" ref="a">
</bean>
5.1 什么是循环依赖?
- 如何解决循环依赖-》set注入可以解决
- Bean的生命周期:容器启动-》构造对象-》set赋值-》后置处理的前置方法-》init-》后置处理的后置方法-》使用对象-》容器关闭-》销毁
6. mysql int(5)和int(11)的区别
- int(M) 中的M指示最大显示宽度,最大有效显示宽度是 255,且显示宽度与存储大小或类型包含的值的范围无关。
- 所以,int(5)与int(11)显示的宽度不同
7. js中json字符串转换集json对象、json对象转换json字符串
json对象-》string JSON.stringify(json对象)
string-》json对象 JSON.parse(json字符串)
8. for和for-each区别,哪个效率更快,原因?
for:通过下标
for-each:采用迭代器进行迭代
9. 常见的异常类有哪些,说出10个?
- NullPointerException
- CastClassException
- RuntimeException
- IOException
- SQLException
- SocketException
- ClassNotFoundException
- ArrayIndexOutOfException
- NumberFormatException
- FileNotFoundException
#### 10. springMVC拦截器怎么配置
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/user/login"/>
<bean class="拦截器">
</mvc:interceptor>
</mvc:interceptors>