小结
三、问题
1、mybatis 会隐性转换,将object的‘1’转为 int类型 ,改为以下方式
<if test="username != null and '' neq username ">
2、解决dao层传递多个字符串参数问题
方式一:
dao
Public User selectUser(String name,String area);
对应mapper.xml
<select id="selectUser" resultMap="BaseResultMap"> select * from user_user_t where user_name = #{0} and user_area=#{1} </select>
#{0}代表接收的是dao层中的第一个参数,#{1}代表dao层中第二参数,更多参数一致往后加即可。
方式二:map传递多参数
dao
Public User selectUser(Map paramMap);
对应的mapper.xml
<select id=" selectUser" resultMap="BaseResultMap"> select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR} </select>
Service层调用:
Private User xxxSelectUser(){ Map paramMap=new hashMap(); paramMap.put(“userName”,”对应具体的参数值”); paramMap.put(“userArea”,”对应具体的参数值”); User user=xxx. selectUser(paramMap);
}
方式三、@param处理
dao层
Public User selectUser(@param(“userName”)String name,@param(“userArea”)String area);
对应mapper.xml
<select id=" selectUser" resultMap="BaseResultMap"> select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR} </select>
3、sql联查
select * from ( select regNo,name,account,wechat,lastLoginTime,contacts,phone,duties,IFNULL(status,10) status from (select name,regNo from com_info) a LEFT JOIN ( select account,wechat,companyKey,MAX(lastLoginTime)as lastLoginTime from u_user LEFT JOIN u_user_role on u_user.userId = u_user_role.userId group by companyKey )b on a.regNo = companyKey LEFT JOIN (select comInfoId,contacts,phone,duties from operator_info WHERE `status` = 1 AND type = 0 group by comInfoId)c on c.comInfoId = a.regNo LEFT JOIN (select companyId,min(status) status from com_perinfo group by companyId) d on d.companyId = a.regNo )a ORDER BY `status`;
【MySql 结论】
order by colum asc 时,null默认被放在最前
order by colum desc 时,null默认被放在最后
ORDER BY IF(ISNULL(update_date),0,1) null被强制放在最前,不为null的按声明顺序[asc|desc]进行排序
ORDER BY IF(ISNULL(update_date),1,0) null被强制放在最后,不为null的按声明顺序[asc|desc]进行排序
4、异常回滚
5、IE浏览器因缓存不兼容的问题
情景一:ajax请求
情景二:get请求
6、前端处理时间显示为nanana问题
初始化时间:
<script> //对Date的扩展,将 Date 转化为指定格式的String //月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, //年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) //例子: //(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 //(new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } </script> <!--毫秒时间转换--> <script type="text/html" id="lastLoginTime"> <span> {{d.lastLoginTime}} </span> </script> 1970年,毫秒时间的转换: {{# //判断为空 if(d.updateTime==null){ return "--"; } //转换 var date = new Date(); date.setTime(d.updateTime); return date.Format("yyyy-MM-dd hh:mm:ss"); }}
7、有关于layui表格初始化问题
情景一:后台通过flag判断
前台:
后台:
情景二:前台统一初始化
8、layui分页与后台响应回页面的数据
9、前端JS定位,赋值
$(".center").children().eq(i+1).html(xxx);
10、页面检查可打印出此对象数据
console.log(xxx);
11、layui表格样式
12、layui中传递参数
13、给图片添加滚轮
<style> .long_demo{background: #888;max-height: 800px;overflow-y: auto;} .long_demo::-webkit-scrollbar {width:8px;height: 1px;} </style>
14、layui图片、pdf弹链接
/*查看图片*/
function lookup(elem) { var imgEle = $(elem).children("img"); console.log(imgEle); console.log( imgEle.attr("src")) if (!imgEle) { layer.alert('暂无信息'); return; } var current_src = imgEle.attr('src'); if (!current_src ||current_src == "unknown" || current_src == "undefined" ) { layer.alert('暂无信息'); layer.alert('暂无信息',{ offset:'100px', }) return; } var current_w = imgEle.width(); var current_h = imgEle.height(); var scale = current_w / current_h; var large_w = current_w * 4; var large_h = large_w / scale; //获取后缀名 var index1=current_src.lastIndexOf("."); var index2=current_src.length; var suffix=current_src.substring(index1+1,index2);//后缀名 console.log(suffix); //弹出pdf文件 if(suffix == "pdf"){ layer.open({ content: '<a href='+current_src+'>点我查看pdf文件</a>', offset:'100px' }) } //非pdf弹出图 if(suffix != "pdf"){ layer.open({ type: 1, title: '', shadeClose: true, shade: [0.8, '#393D49'], area: ['auto', 'auto'], offset:'100px', scrollbar:true, move: '.mine-move', content: '<div class="long_demo"> <img src="' + current_src + '" /></div>' }) } }
15、弹窗前后台数据传输
16、带参数跳转页面
//带参数页面跳转 function jump(url, data) { console.log(data); sessionStorage.setItem("pdata", JSON.stringify(data)); location.href = url; }
jump(adminCtx + '/gbmAccount/check', data);//调用
跳转到的页面,参数的取出
var gdata = JSON.parse(sessionStorage.getItem("pdata"));
smile