qq_28930619 2018-05-16 11:37 采纳率: 25%
浏览 1592
已结题

ssm pageheleper 模糊查询语句出错

@RequestMapping("mohu")
public String mohuchaxun(@RequestParam(value="pn",defaultValue="1")Integer pn,Model model,books bk){
//从第一条开始 每页查询五条数据
PageHelper.startPage(pn, 3);
List users = userService.mohu(bk);

    System.out.println("测试集合有没有获取到数据"+bk.getBookuser());

        System.out.println("大小"+users.size());



    //将用户信息放入PageInfo对象里
    PageInfo page1 = new PageInfo(users,7);
    model.addAttribute("pageInfo2", page1);
    return "mohu";
}
    -----------------------------------------------------------------controller

    <select id="mohu" parameterType="books" resultType="books">
    select * from
    books where bookuser LIKE '%' #{bookuser} '%'
</select>

-------------------------------------------------------------------dao.xml


  <c:forEach items="${pageInfo2.list }" var="user">
                    <tr>
                    <td>${user.bid}</td>
                    <td>${user.bookuser }</td>
                        <td>${user.booktype }</td>
                          <td><img src="${user.bookimg}" width="200" height="100" ></td>
                        <!-- 
                        <td><img src="${user.bookimg}" width="200" height="300" ></td>
                         -->
                        <!-- <td><a  class="edit">编辑</a> <a
                             class="delete">删除</a></td> -->

                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>

    <hr style="height:1px;border:none;border-top:1px solid #ccc;" />
    <!-- 分页导航栏 -->

    <!-- 分页信息 -->
    <div class="row">
        <!-- 分页文字信息,其中分页信息都封装在pageInfo中 -->
        <div class="col-md-6">
            当前第:${pageInfo2.pageNum}页,总共:${pageInfo2.pages}页,总共:${pageInfo2.total}条记录
        </div>

    <!-- 分页条 -->
        <div class="col-md-6">
            <nav aria-label="Page navigation">
              <ul class="hvtulli"  style="list-style-type:none"> 
                <li><a href="${path}/user/mohu?pn=1">首页</a></li>
                <c:if test="${pageInfo2.hasPreviousPage }">
                     <li>
                      <a href="${path}/user/mohu?pn=${pageInfo2.pageNum-1}" aria-label="Previous">
                        <span aria-hidden="true">上一页</span>
                      </a>
                    </li>
                </c:if>

                <c:forEach items="${pageInfo2.navigatepageNums }" var="page_Num">
                    <c:if test="${page_Num == pageInfo2.pageNum }">
                        <li class="active"><a href="#">${ page_Num}</a></li>
                    </c:if>
                    <c:if test="${page_Num != pageInfo2.pageNum }">
                        <li><a href="${path}/user/mohu?pn=${ page_Num}">${ page_Num}</a></li>
                    </c:if>
                </c:forEach> 
                <c:if test="${pageInfo2.hasNextPage }"><a href="${path}/user/mohu?pn=${pageInfo2.pageNum+1}" aria-label="Next">下一页
                      </a>

                </c:if>   
                <a href="${path}/user/mohu?pn=${pageInfo2.pages}">末页</a> 

-----------------------------------------------------------jsp
普通的查询这样都可以做到。 但是这个模糊查询,点击首页或者末页就会报错,
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null '%') tmp_count' at line 2

The error may exist in com/ssm/dao/Userdao.xml

The error may involve com.ssm.dao.Userdao.mohu-Inline

The error occurred while setting parameters

SQL: select count(0) from (select * from books where bookuser LIKE '%' ? '%') tmp_count

知道是sql的错误, 请大神帮我看看怎么办。 我是初学者。

  • 写回答

7条回答

  • 余新 2018-05-16 11:47
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?