📄 testfilter.java
字号:
package apibook.c7.s1;import javax.servlet.*;import java.io.IOException;import javax.servlet.http.*;//测试Filter接口public class TestFilter implements Filter { FilterConfig config; public TestFilter() { } public void setFilterConfig(FilterConfig config) { this.config = config; } public FilterConfig getFilterConfig() { return config; } public static void main(String[] args) { TestFilter testFilter1 = new TestFilter(); } public void init(FilterConfig parm1) throws javax.servlet.ServletException { /**@todo Implement this javax.servlet.Filter method*/ throw new java.lang.UnsupportedOperationException("Method init() not yet implemented."); } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws java.io.IOException, javax.servlet.ServletException { ServletContext context = getFilterConfig().getServletContext(); long bef = System.currentTimeMillis(); chain.doFilter(req, res); // no chain parameter needed here long aft = System.currentTimeMillis(); context.log("Request to " + req.getServerName() + ": " + (aft-bef));//.getRequestURI() } public void destroy() { /**@todo Implement this javax.servlet.Filter method*/ throw new java.lang.UnsupportedOperationException("Method destroy() not yet implemented."); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -