当前位置: 首页 > news >正文

做试卷挣钱的网站北京app网站建设价格

做试卷挣钱的网站,北京app网站建设价格,搜索量排名,房地产市场现状分析2022项目场景#xff1a; CRM项目#xff0c;本文遇到的问题是在实现根据页面表单中输入条件#xff0c;在数据库中分页模糊查询数据#xff0c;并在页面分页显示的功能时#xff0c;出现的“诡异”bug。 开发环境如下#xff1a; 操作系统#xff1a;Windows11 Java#…项目场景 CRM项目本文遇到的问题是在实现根据页面表单中输入条件在数据库中分页模糊查询数据并在页面分页显示的功能时出现的“诡异”bug。 开发环境如下 操作系统Windows11 Javajdk-21.0.2 IDEeclipse 2024-3R Tomcatapache-tomcat-10.1.11 Mavenapache-maven-3.9.6 数据库MariaDB11.0 项目地址https://gitcode.com/weixin_44803446/crm-project.git 问题描述 在项目中通过一下两个查询分别查询对象列表跟总条数通过日期查询及空条件查询结果均无异常但是在通过名称及所有者名称进行模糊查询时返回的查询结果为0即使是全字段匹配也无法正常查询到想要的数据Mapper文件片段如代码所示 !-- 通过条件查询市场活动表 --select idselectActivityListByConditionForPage parameterTypemap resultMapBaseResultMapselect a.id, a.name, u1.name as owner, a.start_date, a.end_date, a.cost, u2.name as create_by, a.create_timefrom tbl_activity ajoin tbl_user u1 on a.owner u1.idjoin tbl_user u2 on a.create_by u2.idwhereif testname ! null and name !and a.name like %#{name}% /ifif testowner ! null and owner ! and u1.name like %#{owner}% /ifif teststartDate ! null and startDate ! and a.start_date gt; #{startDate}/ifif testendDate ! null and endDate ! and a.end_date lt; #{endDate} /if/whereorder by a.create_time desclimit #{beginNo},#{pageSize}/select!-- 查询对应条件下的市场活动总条数 --select idselectActivityCounts parameterTypemap resultTypeintselect count(*)from tbl_activity ajoin tbl_user u1 on a.owner u1.idjoin tbl_user u2 on a.create_by u2.idwhereif testname ! null and name !and a.name like %#{name}% /ifif testowner ! null and owner ! and u1.name like %#{owner}% /ifif teststartDate ! null and startDate ! and a.start_date gt; #{startDate}/ifif testendDate ! null and endDate ! and a.end_date lt; #{endDate} /if/where/select原因分析 首先确定前端的字段是否完整的传递到Controller通过Console.log(参数)的方式将参数打印在浏览器控制台中经过验证参数传递无异常其次在Controller及Service中获取参数并打印确保参数传递过程没有缺失等查看查询日志 JDBC Connection [org.mariadb.jdbc.Connection5516cc8d] will be managed by SpringPreparing: select a.id, a.name, u1.name as owner, a.start_date, a.end_date,a.cost, u2.name as create_by, a.create_time from tbl_activity a join tbl_user u 1 on a.owner u1.id join tbl_user u2 on a.create_by u2.id WHERE a.name like %?% order by a.create_time desc limit ?,?Parameters: n(String), 0(Integer), 10(Integer)Total: 0 Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSq lSession2ef7efff] Transaction synchronization committing SqlSession [org.apache.ibatis.session.def aults.DefaultSqlSession2ef7efff] Transaction synchronization deregistering SqlSession [org.apache.ibatis.session. defaults.DefaultSqlSession2ef7efff] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaul ts.DefaultSqlSession2ef7efff] Creating a new SqlSession Registering transaction synchronization for SqlSession [org.apache.ibatis.sessio n.defaults.DefaultSqlSession66e3b3d0] JDBC Connection [org.mariadb.jdbc.Connectionb60a270] will be managed by SpringPreparing: select count(*) from tbl_activity a join tbl_user u1 on a.owner u1.id join tbl_user u2 on a.create_by u2.id WHERE a.name like %?%Parameters: n(String)Columns: count(*)Row: 0Total: 1 Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSq lSession66e3b3d0] Transaction synchronization committing SqlSession [org.apache.ibatis.session.def aults.DefaultSqlSession66e3b3d0] Transaction synchronization deregistering SqlSession [org.apache.ibatis.session. defaults.DefaultSqlSession66e3b3d0] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaul ts.DefaultSqlSession66e3b3d0]由数据库查询日志可以看出在执行模糊查询时参数准确无误的传递到了Sql语句中但是经过模糊查询后查到的数量Total为0但是实际上数据库中是有一条符合模糊条件的数据的。 猜想 if testname ! null and name !and a.name like %#{name}% /if这一句模糊查询语句有问题尝试在’%‘与#{name} 之间加上空格后重启服务器测试发现模糊查询功能正常。问题就出在MyBatis在处理字符串拼接时如果以’%‘#{name}’%’ 这样紧密的格式书写则会导致其将整个字段识别为一个整体最终的拼接体可能为%‘#{name}’%。 解决方案 通过在#{name}前后添加空格让MyBatis正确的识别并拼接参数与字符串更严谨的方式是使用CONCAT函数通过CONCAT()函数将% 与#{name}拼接起来这样避免了因为拼写错误等原因导致最终SQL与我们预想的不一致的情况。 !-- 通过条件查询市场活动表 --select idselectActivityListByConditionForPage parameterTypemap resultMapBaseResultMapselect a.id, a.name, u1.name as owner, a.start_date, a.end_date, a.cost, u2.name as create_by, a.create_timefrom tbl_activity ajoin tbl_user u1 on a.owner u1.idjoin tbl_user u2 on a.create_by u2.idwhereif testname ! null and name !and a.name like concat(%,#{name},%)/ifif testowner ! null and owner ! and u1.name like concat(%, #{owner},% )/ifif teststartDate ! null and startDate ! and a.start_date gt; #{startDate}/ifif testendDate ! null and endDate ! and a.end_date lt; #{endDate} /if/whereorder by a.create_time desclimit #{beginNo},#{pageSize}/select!-- 查询对应条件下的市场活动总条数 --select idselectActivityCounts parameterTypemap resultTypeintselect count(*)from tbl_activity ajoin tbl_user u1 on a.owner u1.idjoin tbl_user u2 on a.create_by u2.idwhereif testname ! null and name !and a.name like concat(%,#{name},%)/ifif testowner ! null and owner ! and u1.name like concat(%, #{owner},% )/ifif teststartDate ! null and startDate ! and a.start_date gt; #{startDate}/ifif testendDate ! null and endDate ! and a.end_date lt; #{endDate} /if/where/select
http://www.dnsts.com.cn/news/262708.html

相关文章:

  • 软件开发包含网站开发电商培训心得
  • 阿里云wordpress安装seo系统源码出售
  • 南京关键词网站排名学生如何建设网站
  • 个人做网站怎么盈利90设计
  • 培训教育类网站模板北京云无限优化
  • 网页做网站的尺寸wordpress前台管理员
  • wordpress 移动建站项目计划书范文
  • 微信上做任务让你注册彩票网站无锡网站制作一般多少钱
  • 网站如何做导航条做赌场网站犯法么
  • 大连淘宝网站建设wap网
  • 上海网站制作价格企业网盘哪个最好用
  • 怎样做网站能百度能搜到列表页面设计模板
  • 品牌网站建设小蝌蚪c彭阳门户网站建设
  • 手机网站违规禁止访问怎么办重庆招聘网站建设
  • 手机网站 代码格式网络营销的七种方法
  • 做小程序的公司有哪些比较好?精选网站建立 推广 优化
  • 网站建设团队与分工重庆网站开发价格
  • dw网站制作模板品牌设计
  • 前端如何兼职做网站企业网站系统设计论文
  • 网站页面一般做多大西安城乡住房建设厅网站首页
  • 扬州建设银行网站大型网站建设 教程
  • 如何建设一个文件分享网站抖音广告推广
  • 响应式网站检测工具广州网站建设+致茂
  • 做网站的平台有哪些seo怎么去优化
  • 婚纱摄影网站设计思路网站建设方案项目书
  • 网站如果不备案网络推广引流最快方法
  • 购物网站建设好处WordPress图床api
  • 网站鼠标经过图片代码网站后台如何上传文件
  • 婚庆网站设计说明书网站建设做网站怎么做
  • 象58同城网站建设需要多少钱建筑学太烧钱了