学习杂物(一)java学习笔记

1、Map的初始化:

Map<String,Object> map = new HashMap<>();

2、Sql的case when方法:

(case 字段 
 when '字段值' then '替换的值'
 when '字段值' then '替换的值'
 else '替换的值'
end)

else如果有需求可以有时候不放

3、JSP里的c标签if用法

<c:if text="值的判断句">
    ……if里要执行的内容……
</c:if>

例如:

<c:if test="${tEFeedbackPage.feedStatus == 1}">
    <input value="未回复" />
</c:if>

4、JSP里的c标签forEach遍历List的用法

<c:forEach items="${传来的遍历的List名}" var="循环List的别名">
    <input value='${listAns.nickname}' />
    <input value='${listAns.time}' />
</c:forEach >

var中可以用这些属性值:
index当前这次迭代从 0 开始的迭代索引
count当前这次迭代从 1 开始的迭代计数
first用来表明当前这轮迭代是否为第一次迭代的标志
last用来表明当前这轮迭代是否为最后一次迭代的标志
begin属性值开始的位置
end属性值结束的位置
step属性值迭代步长

5、MiniDao里的 <#if> 在模糊查询的用法(例如)

SELECT
(select count(1) from t_e_answer t4 where t1.id=t4.question_id) as ansNum,
t1.id,
t2.typecode,
t1.question_title AS questionTitle,
t1.question_status AS questionStatus,
t1.question_time AS questionTime,
t3.nickname,
t1.scan_num AS scanNum
FROM t_e_question t1
INNER JOIN t_s_type t2 ON t1.question_type = t2.typecode
INNER JOIN t_e_person t3 ON t1.person_id = t3.id
WHERE t1.del_flag = 0
<#if tEQuestionEntity.questionTitle ?exists && tEQuestionEntity.questionTitle ?length gt 0>
    and t1.question_title like concat('%',:tEQuestionEntity.questionTitle, '%')
</#if>
<#if tEQuestionEntity.questionStatus ?exists && tEQuestionEntity.questionStatus ?length gt 0>
    and t1.question_status = :tEQuestionEntity.questionStatus
</#if>
<#if timeGroupDto.questionTime_begin ?exists && timeGroupDto.questionTime_begin ?length gt 0 && timeGroupDto.questionTime_end ?exists && timeGroupDto.questionTime_end ?length gt 0>
    and t1.question_time BETWEEN :timeGroupDto.questionTime_begin and :timeGroupDto.questionTime_end
</#if>
<#if nickname ?exists && nickname ?length gt 0>
    and t3.nickname like concat('%',:nickname, '%')
</#if>
<#if tEQuestionEntity.scanNum ?exists && tEQuestionEntity.scanNum ?length gt 0>
    and t1.scan_num = :tEQuestionEntity.scanNum
</#if>
<#if typecode ?exists && typecode ?length gt 0>
    and t2.typecode  like concat('%',:typecode, '%')
</#if>
<#if index ?exists && index ?length gt 0 && columns ?exists && index ?length gt 0>
    ORDER BY  ${columns}  ${index}
</#if>
LIMIT :pageIndex,:rows
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值