基于javaee基础上运行的一个web容器
http 服务器
socktet上支持 TCP/IP HTTP FTP
接受客户端的一个http url请求,对应后台有一个servlet
netty属于协议层,底层框架。
request response
4.0版本
public class DNTomcat{
public void start(int port){
Event LoopGroup bossGroup=new NioEventLoopGroup();
EventLoopGroup workGroup=new NioEventLoopGroup();
ServerBootstrap b=new ServerBootstrap();
b.group(bossGroup,workGroup).channel(NioServerSocketChannel.class).
childHandler(new ChannelInitializer
protected void initChannel(SocketChannel args0) throws Excepton{
sc.pipeline().addLast(new HttpResponseEncoder());
sc.pipeline().addLast(new HttpRequestDecoder());
sc.pipeline().addLast(new DNTomcatHandler());
}})
.option(ChannelOption.SO_+BACKLOG,128)
.childOption(ChannelOption.SO_KEEPALIVE,true);
ChannelFutrue f=b.bind(port).sync();
f.channel
}
}
public class DNResponseP
}
public class DNTomcatHandler
web.xml
name
className
private static final Map
Pattern=pattern.replacAll("\\.",*");
String className=CustomConfig.getString("servlet");
if(!ServletMapping.containsKey(pattern)
servletMapping.put())
static{
for(String key:CustomConfig.getKeys()){
if(key.startWith("servlet")){
String name=key.replaceFirst("servlet","");
else{
continue;
String pattern=CustomConig.getString("servlet"+name+"urlPattern");
String className=CustomConfig.getString("Servlet.");
for(Entry
if(entry.getKey().matcher(uri).matches()){
DNServlet serlet (DNServlet)entry.getValue().newInstancse();
if("get".equesIgnoreCase(method)){
servlet.doGet(request,response);
}else{
servlet.doPost(request,response);
}?
if(!hasPattern){
String out=String.format("404not Found,URL:%S,method:%S",uri,method);
}
serlvet.fist.urlPattern=/first/quey*