Tomcat多项目多端口配置

<Service name="Catalina1">
    <Connector port="8081" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina1" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost"  appBase="webapps1"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>

  <Service name="Catalina2">
    <Connector port="8082" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina2" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost"  appBase="webapps2"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>

Bootstrap简单例子

<body style="margin-left:300px;">
	<div style="height:100px;"></div>
	<input type="text" class="form-control" placeholder="Text Wait input" style="width:200px;">
	<p />

	<div class="panel panel-success" style="width:60%">
	  <!-- Default panel contents -->
	  <div class="panel-heading">Panel heading</div>

	  <!-- Table -->
	  <table class="table table-striped table-hover nth-child table-bordered">
		<tr class="active">
			<th>Name</th>
			<th>Age</th>
			<th>Sex</th>
		</tr>
		<tr>
			<td>ZhangSan</td>
			<td>15 Years Old</td>
			<td>Female</td>
		</tr>
	  </table>
	</div>

	<button type="button" class="btn btn-lg btn-primary">Save Action</button>
	<button type="button" class="btn btn-lg btn-info">Info Action</button>
 </body>

java操作mongodb示例2

public class SimpleCRUDTest {
	private Mongo mongo = null;
	private DB db = null;
	private DBCollection collection = null;
	public SimpleCRUDTest(){
		try {
			mongo = new Mongo();
			db = mongo.getDB("test");
			collection = db.getCollection("things");
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
	
	public void queryAll(){
		DBCursor cursor = collection.find();
		while(cursor.hasNext()){
			System.out.println(cursor.next());
		}
	}
	
	public void simpleAdd(){
		DBObject object = new BasicDBObject();
		object.put("name", "long0416");
		object.put("age", 12);
		object.put("sex", "male");
		WriteResult result = collection.save(object);
		System.out.println("受影响条数: " + result.getN());
	}
	
	public void complexAdd(){
		List<DBObject> objectList = new ArrayList<DBObject>();
		DBObject object = new BasicDBObject();
		object.put("name", "longtest1");
		object.put("sex", "female");
		
		DBObject object2 = new BasicDBObject();
		object2.put("name", "longtest2");
		object2.put("age", 11);
		
		objectList.add(object);
		objectList.add(object2);
		
		collection.insert(objectList);
	}
	
	public void update(){
		BasicDBObject updateObject = new BasicDBObject();
		updateObject.put("x", 4.0);
		updateObject.put("j", "sss");
		WriteResult result = collection.update(new BasicDBObject("x", 4.0), updateObject);
		System.out.println("受影响条数:" + result);
	}
	
	public void findAndUpdate(){
		BasicDBObject updateObject = new BasicDBObject();
		updateObject.put("x", 4.0);
		updateObject.put("j", "tt");
		DBObject object = collection.findAndModify(new BasicDBObject("x", 4.0), updateObject);
		System.out.println(object);
	}
	
	public void remove(){
		System.out.println(collection.remove(new BasicDBObject("j", new BasicDBObject("$gte", 8))).getN());
	}
	
	public static void main(String[] args) {
		SimpleCRUDTest simpleTest = new SimpleCRUDTest();
		System.out.println("添加前");
		simpleTest.queryAll();
		System.out.println("添加开始");
		// simpleTest.simpleAdd();
		// simpleTest.complexAdd();
		// simpleTest.update();
		// simpleTest.remove();
		//simpleTest.findAndUpdate();
		//simpleTest.queryAll();
		System.out.println("添加结束");
	}

java操作mongodb简单示例

public class SimpleTest {
	public static void main(String[] args) {
		Mongo mongo;
		try {
			mongo = new Mongo();
			List<String> dbNames = mongo.getDatabaseNames();
			for(String dbName : dbNames){
				System.out.println(dbName);
			}
			DB db = mongo.getDB("test");
			System.out.println("======================================");
			Set<String> collectionSet = db.getCollectionNames();
			for(String collectionName : collectionSet){
				System.out.println(collectionName);
			}
			DBCollection collection = db.getCollection("things");
			DBCursor cursor = collection.find();
			while(cursor.hasNext()){
				DBObject object = cursor.next();
				System.out.println(object);
			}
			System.out.println("count:" + cursor.count());
			//System.out.println("length: " + cursor.length());
			System.out.println("size: " + cursor.size());
			System.out.println("cursorId: " + cursor.getCursorId());
			System.out.println("json: " + JSON.serialize(cursor));
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
}