如何将值传到相应位置?

//得到当前用户[从session取出]
Users loginUser = (Users) request.getSession().getAttribute("loginuser");
this.pageBean = articleService.queryForPage("from Article where users.id=?", 10, page); //获取封装了分页信息和数据的pageBean
我想将loginUser.getId()这个值传到“from Article where users.id=? ”中问号这个地方,代码应该怎么写?

直接连接组合成sql语句,要不就用PrepareStatement执行带参数语句:http://www.worlduc.com/blog2012.aspx?bid=11688059

 articleService.queryForPage("from Article where users.id="+loginUser.id, 10, page); 

PreparedStatement ps = con.prepareStatement("select * from Article where users.id=?");
updateSales.setInt(1, loginUser.id);

直接拼接也可以用PreparedStatement 也是可以的

最好使用PreparedStatement吧,防sql注入