实例:
Server server=new Server();
SocketListener listener=new SocketListener();
listener.setPort(80);
//创建context
WebApplicationContext webcontext=new WebApplicationContext("app");
//不需要显式的给webcontext添加handler
webcontext.setContextPath("/");//访问时候需要输的url
webcontext.setResourceBase("./app");//设置资源路径
//注:这个的context是webapplicationcontext 参数"app" 是工程文件夹下的app目录
webcontext.addServlet("test", "/test/*","SimpleServlet");
//给context添加一个servlet
然后启动这个server
使用http://localhost/test/ 来访问该服务器 就是调用了该SimpleServlet