1
如何讓我的查詢只返回它的數據,而不是現場,蒙戈Java驅動程序,只得到數據未字段名
例如,這是我的代碼
Pattern pattern = Pattern.compile(".*"+textArea.getText()+".*", Pattern.CASE_INSENSITIVE);
BasicDBObject query = new BasicDBObject("content:encoded", pattern);
model.setRowCount(0);
BasicDBObject field = new BasicDBObject();
field.put("title", 1);
field.put("_id", 0);
DBCursor cursor = blogTable.find(query,field);
String[] columnNames = {"Title"}; //Jtable headings
while (cursor.hasNext())
{
model.addRow(new Object[]{cursor.next().toString()});
}
和這是我得到的輸出是
{ "title" : "Friday - 9/24/2012"}
{ "title" : "Picture from Pile Gate in Dubrovnik"}
{ "title" : "Saturday - 8/25/2012 - In search of the coffee press"}
{ "title" : "Concert at Church of St. Blaise"}
{ "title" : "DSCN0040"}
{ "title" : "DSCN0041"}
{ "title" : "DSCN0043"}
{ "title" : "DSCN0042"}
我希望它只有數據部分即
Friday - 9/24/2012
Picture from Pile Gate in Dubrovnik
Saturday - 8/25/2012 - In search of the coffee press
Concert at Church of St. Blaise
DSCN0040
在此先感謝。
感謝它的工作! – Snedden27