问题如题。
贴一段正则表达式的代码,求解答
@IocBean
public class UserService {
// 按需注入几个核心对象
@Inject
protected ZMongo zMongo; // 注意大小写与配置的名字一致
@Inject
protected ZMoDB zMoDB; // 当前
@Inject
ZMoCo zMoCo;
public List<User> query(ZMoDoc cnd) {
List<User> list = new ArrayList<User>();
DBCursor cursor = zMoCo.find(cnd);
while (cursor.hasNext()) {
DBObject obj = cursor.next();
list.add(ZMo.me().fromDocToObj(obj, User.class));
}
return list;
}
public static void main(String[] args) {
UserService userService = MongoDB.ioc.get(UserService.class);
List<User> userList = userService.query(ZMoDoc.NEW("{'name':'/o/i'}"));
for (User user2 : userList) {
System.out.println(user2.toString());
}
}
}
日志中无内容打印
数据库数据如下:
/* 1 */
{
"_id" : ObjectId("58046202f9c5ff1a10b82400"),
"age" : "15",
"name" : "OK",
"id" : 1
}
/* 2 */
{
"_id" : ObjectId("5805b21c478e3386ca09e52a"),
"age" : 1.0,
"name" : "tom"
}