Servlet3

阅读更多

一、注解一个Servlet3规范的Servlet

@WebServlet(name="hello",asyncSupported=true, 
		loadOnStartup=2,
		urlPatterns = { "/test/hello" },
		initParams={@WebInitParam(name="config",value="config.xml")}  
)
public class Hello extends HttpServlet 

 二、Listener注解

@WebListener("This is a servlet3 listener test on startUp")
public class ListenerOnStart implements ServletContextListener

 三、Filter注解

@WebFilter(
		 dispatcherTypes = {
		   DispatcherType.REQUEST, 
		   DispatcherType.FORWARD,
		   DispatcherType.INCLUDE
		 }, 
		 urlPatterns = { "/test/LogServlet" }, 
		 asyncSupported = true //支持异步Servlet
		)
public class LogFilter implements Filter 

 四、web.xml中的头


 其中如web.xml中的Filter,Servlet有过滤到该URL时,如果该Servlet需要支持异步,请将这些Filter,Servlet添加

true 
 

 

你可能感兴趣的:(Servlet3,filter,Listener)