大神们帮忙一下

心大自然宽 2020-11-23 04:13:54
根据搜索框里输入的内容到后台数据库进行模糊查询该怎么写

在title 和sub_title这两个字段进行模糊查询

大神帮帮忙帮写一下
...全文
1025 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
是赵敢敢啊 2020-11-23
  • 打赏
  • 举报
回复
controller写错了
心大自然宽 2020-11-23
  • 打赏
  • 举报
回复
引用 3 楼 景初JingChu丶 的回复:
select * from tableName Where title like '%查询内容%' or sub_title like '%查询内容%'
有了SQL语句了,但是搜索框输入内容后台接受过来报错Field error in object 'testpojo' on field 'id': rejected value [成功]; codes [typeMismatch.testpojo.id,typeMismatch.id,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [testpojo.id,id]; arguments []; default message [id]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'id'; nested exception is java.lang.NumberFormatException: For input string: "成功"]]
  • 打赏
  • 举报
回复
select * from tableName Where title like '%查询内容%' or sub_title like '%查询内容%'
源者鬼道 2020-11-23
  • 打赏
  • 举报
回复
难道不是直接使用like关键字对字段内容执行模糊查询嘛?有什么其他的技术要求难点嘛
心大自然宽 2020-11-23
  • 打赏
  • 举报
回复
我自己顶一下

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧