如果总分110分,你能打几分?
1.
在
SpringMVC
的 配 置 文 件 中 , 定 义 控 制 器 搜 索 路 径 的 标 记 是<context:component-scan>
。
2.
表单的请求参数可以自动注入给控制器的同名形参。
3. SpringMVC
的控制器响应
JSON
数据需要在控制器前注解
@ResponseBody
。
4.
在
MyBatis
中,
①
、
MyBatis
的缓存分为一级缓存和二级缓存;
②
、二级缓存可以被所有的
SqlSession
共享;
③
、在映射文件中默认是没有开启二级缓存的,开启二级缓存需要使用
cache
标签;
5.
通过以下配置判断,
Goods
类中可能有一个
List
集合
<resultMap id="goodsResultMap" type="com.isoft.pojo.Goods">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="price" column="price"/>
<collection property="goodImgs" resultMap="goodsResultMap"/>
</resultMap>
6.
如下配置:
<select id="sqlLog" parameterType="appLog" resultType="appLog">
select * from t_applog where
<if test="title!=null">
title=#{title}
</if>
<if test="content!=null">
and content=#{content}
</if>
</select>
①
、这个配置存在问题,当第一个
if
语句不成立时
Where
后面紧跟
and
是一个错误的
SQL
语句,将出现运行时异常
②
、为了解决
title
为
null
时的运行时异常我们可以用
<where>
标签把所有
<if>
包含起来
③
、为了解决
title
为
null
时的运行时异常我们可以用
<trim prefix=
”
whereprefixOverrides=
”
and | or
”
></trim>
把所有
<if>
包含起来,并把
where
去掉。
7.
关于
MyBatis
的全局配置文件中,
settings
元素设置项的默认值为
false
的是
useGeneratedKeys
。
8.
在一个
MyBatis
的应用中,关于
SlqSessionFactoryfBuilder
,
SqlSessionFactory
以及
SqlSession
的应用范围和生命周期,
①
、
SlqSessionFactoryfBuilder
的最佳范围是方法范围,即可以定义为本地方法变量
②
、
SqlSessionFactory
的最佳范围是应用范围
③
、
SqlSession
的最佳范围是方法范围或请求范围
9. Mybatis
可以利用
Sql
映射文件配置,也可以利用
Annotation
来设置,基本注解的是
@Arg
;
@Case
;
@Results
;
10. @One
注解,复杂类型的单独属性映射。
11. SpringMVC
中使用注解
@Controller
定义控制器。
12. SpringMVC
中,当前控制器返回值应该包括字符串
forward
才能保证携带请求数据
跳转到另一个控制器。
13.
在请求的过程中,
SpringMVC
使用接口
Converter
的实现类完成数据类型转换。
14.
以下关于
MyBatis
的使用场景描述
①
、 当希望对象的持久化对应用程序完全透明时不适合使用
MyBatis
;
②
、当数据库有移植需求或需要支持多种数据库时不适合使用
MyBatis
;
③
、当应用程序需要完全动态的
sql
时不适合使用
MyBatis
;
15.
在
MyBatis
的
Mapper
文件中,
①
、
<select id="queryUserById" resultType="hashmap" parameterType="int">
<![CDATA[select * from user u where u.id=#{id}
]]>
</select>
②
、
<delete id="deleteUserById" parameterType="int">
<![CDATA[delete from user u where u.id=#{id}
]]>
</delete>
③
、
<update id="updateUser" parameterType="User">
<![CDATA[update user set username=#{username},passwd=#{passwd} where id=#{id}
]]>
</update>
16.
如果想让
MyBatis
将日志信息输出到屏幕,
<settings>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
17.
在
Mybatis
中,关于
<resultmap>
和
<collection>
元素
①
、
<collection>
通过
property
属性指定实体类中集合属性的名字;
②
、
<collection>
通过
javaType
属性指定实体类中元素的类型;
③
、
<collection>
通过
javaType
属性指定集合的类型;
18.
在
Mybatis
中,关于
ResultType
①
、
resultType
表示返回值类型为:完整类名或别名,
MyBatis
也允许使用基本的数据
类型,包括
String
、
int
类型;
②
、
resultType
和
resultMap
的数据结构是一样的,都是
Map
;
③
、
resultType
和
resultMap
不能同时使用;
19. Mybatis
注解的标签是
@select
;
@udpate
;
@delte
;
20.
注解
@RequestMapping()
主要用来定义控制器的请求名称,该标记可以放置的位置
是可以在方法和类前。
21.
在
SpringMVC
中,使用注解
@SessionAttributes
指定
Session
属性。
22. SpringMVC
实现国际化操作中,使用
Spring
标签
<spring:message>
完成国际化信息
的显示。
23. ResultType
取值
①
、
<select id="selectPersonCount" resultType="int">
select count(*) from person
</select>
②
、
<select id="selectPersonCount" resultType="_int">
select count(*) from person
</select>
③
、
<select id="selectPersonCount" resultType="java.lang.Integer">
select count(*) from person
</select>
24.
如果想让
MyBatis
将日志信息输出到屏幕,则:
<settings>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
25. MyBatis
的使用场景描述
①
、当希望对象的持久化对应用程序完全透明时不适合使用
MyBatis
;
②
、当数据库有移植需求或需要支持多种数据库时不适合使用
MyBatis
;
③
、当应用程序需要完全动态的
sql
时不适合使用
MyBatis
;
26. @Arg