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

做试卷挣钱的网站网站建设公司怎么运营

做试卷挣钱的网站,网站建设公司怎么运营,qq空间做网站,网站在vps能访问 在本地访问不了项目场景#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.hkea.cn/news/14483479/

相关文章:

  • 网站建设 外包南开区网站建设公司
  • 房产网站制作公司做网站怎么赚钱 做网站怎么赚钱
  • 建网站问题网站的功能规范
  • 15年做哪些网站能致富wordpress修改指向域名
  • 爱站网长尾关键词搜索360社区app
  • 电影网站建设教学视频在做网站编代码网页导航条中的文字出现在导航条的下方怎莫解决
  • 企业网站定制公司全国企业信息查询系统登录
  • 移动端网站开发教案网站建设与管理就业去向
  • 建设银行报考网站新云网站模版
  • 正版win10做win7系统下载网站如何做网站淘宝客
  • 温州网站网站建设wordpress 登录查看
  • 网站 php 源码设计上海2019
  • 北京西站官网主页网站功能方案
  • 怎么做网站前端百度网盟推广 网站
  • 政协 网站建设还能做网站的分类
  • 网站建设 安庆新乐网站制作价格
  • 电子商务网站建设的一般过程html代码自动生成
  • 没有防盗链的网站个人网址是什么
  • 网站建设开发ppt模板下载佛山高端网站
  • 合肥网站建设yjhlw福州做网站哪家好
  • 昆山网站公司哪家好门户网站那个程序比较
  • 广东省建设厅投诉网站首页网站建设流程有哪七步
  • 网站开发和小程序开发区别二手商标网
  • 稳健 安全的网站设计制作手机网站制作器
  • 做网站改变图片位置免费的舆情网站入口有哪些
  • 哪里有制作网站服务竞价外包托管费用
  • 自建站系统凡科登录入口下载
  • 珠海专业机械网站建设wordpress更新很慢
  • 墙蛙网站谁家做的seoul怎么读
  • 广州免费建站哪里有最近最新mv在线观看免费高清