本文小编为大家详细介绍“Mybatis中的常用OGNL表达式有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“Mybatis中的常用OGNL表达式有哪些”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
1、e1 or e2:或
<if test="userEmail != null or userEmail == '1'">
</if>
2、e1 and e2:且
<if test="userEmail != null and userEmail != ''">
</if>
3、e1 == e2 或e1 eq e2:相等
<if test="userEmail == null and userEmail == ''">
</if>
4、e1 != e2 或 e1 neq e2:不等
<if test="userEmail != null and userEmail != ''">
</if>
5、e1 lt e2:小于
<if test="age lt 10">
#{userEmail,jdbcType=VARCHAR},
</if>
6、e1 lte e2:小于等于
7、e1 gt e2:大于
8、e1 gte e2:大于等于
9、 e1 + e2(加),e1 - e2(减),e1 * e2(乘),e1/e2(除),e1%e2(余)
10、!e或not e:非,取反
11、e.method(args):调用对象方法
<if test="list != null and list.size() > 0 ">
#{userEmail,jdbcType=VARCHAR},
</if>
12、e.property:对象属性值
<!-- 多接口参数的查询方法(@Param + javaBean方式) -->
<select id="selectByUserIdAndEnabledUseBean" resultMap="BaseResultMap">
select r.id, r.role_name, r.enabled, r.create_by, r.create_time,
u.user_name as "user.userName", u.user_email as "user.userEmail"
from sys_user u
inner join sys_user_role ur on u.id = ur.user_id
inner join sys_role r on ur.role_id = r.id
where u.id = #{user.id} and r.enabled = #{role.enabled}
</select>
13、e1[e2]:按索引取值(List、数组和map)
14、@class@method(args):调用类的静态方法
<bind name="name" value="@ex.mybatis.rbac.mapper.UserMaperTest@setName()"/>
15、@class@field:调用类的静态字段值
<bind name="name" value="@ex.mybatis.rbac.mapper.UserMaperTest@NAME"/>
写了一个特别简单的小例子,使用struts1+mybatis+spring,,,其中做了一个增删改查,
结果遇到了一个特别无知的错误!以后一定要记住,不能再犯了!
我在数据库中建的表的字段是xx_xx这种格式的,例如notice_title,在pojo实体类中定义的属性是noticeTitle这种形式的,
在做查找所有数据的时候,sql语句中对各个字段起了别名,但是别名没有与pojo类的属性名对应,导致resultMap对应的类不能与自己起的别名对应,导致不能进行实体类封装值
public ActionForward show(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<Notice> noticeList = noticeService.getNoticeList();
request.setAttribute("noticeList", noticeList);
return mapping.findForward("begin");
}
<table border="1">
<tr>
<td>选择</td>
<td>主题</td>
<td>内容</td>
<td>发表时间</td>
<td>备注</td>
<td>编辑人员</td>
</tr>
<c:forEach var="notices" items="${requestScope.noticeList }" >
<tr>
<td><input type="checkbox" name="keyid" value="${notices.keyid}"/></td>
<td>${notices.noticeTitle}</td>
<td>${notices.noticeContent }</td>
<td>${notices.noticePublishTime}</td>
<td>${notices.noticeComment}</td>
<td>${notices.noticeEditor }</td>
</tr>
</c:forEach>
</table>
读到这里,这篇“Mybatis中的常用OGNL表达式有哪些”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。