public static void main(String[] args) {
Server server = new Server(port);
File rootDir = new File(WAR_LOCATION);
List<Handler> appList=new ArrayList<Handler>();
if(!rootDir.isDirectory()){
}else{
String[] fileList = rootDir.list();
Handler[] handlerAry= new Handler[fileList.length];
for (int i = 0; i < fileList.length; i++) {
int index=i+1;
String projectName=fileList[i];
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/"+projectName);
webAppContext.setWar(WAR_LOCATION+"/"+projectName);
/// webAppContext.setResourceBase(WAR_LOCATION+"/");
webAppContext.setParentLoaderPriority(true);
handlerAry[i]=webAppContext;
}
HandlerCollection hc =new HandlerCollection();
// hc.setHandlers(new Handler[]{webAppContext,webAppContext2});
hc.setHandlers(handlerAry);
server.setHandler(hc);
}
try {
server.start();
server.join();
logger.info("WEB服務成功啟動。IP:"+getIp()+",連接埠:"+port);
} catch (Exception e) {
e.printStackTrace();
}
}