主题:请高手看看我Filter启动tomcat是出错的原因
java源程序如下
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* 计算并记录请求的响应时间到日志文件
*/
public class ResponseTimeFilter implements Filter {
protected FilterConfig config;
public void init(FilterConfig filterConfig) throws ServletException {
this.config = filterConfig;
}
// 需要重点实现的方法
public void doFilter(
ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// 响应开始时间
long startTime = System.currentTimeMillis();
// 将请求转发给过滤器链上其他对象
chain.doFilter(request, response);
// 计算请求的响应时间
long elapsed = System.currentTimeMillis() - startTime;
String name = "default";
if (request instanceof HttpServletRequest) {
name = ((HttpServletRequest) request).getRequestURI();
}
// 将请求的响应时间记录到日志文件
config.getServletContext().log(name + " took " + elapsed + " ms");
}
public void destroy() {
}
}
wed.xml配置信息如下
<filter>
<filter-name>RseponseTimeFilter</filter-name>
<filter-class>ch16.RseponseTimeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RseponseTimeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
启动tomcat是出现如下错误信息
严重: Error filterStart
2007-11-16 10:01:34 org.apache.catalina.core.StandardContext start
严重: Context [/serlet] startup failed due to previous errors
请高手看看.原因是什么.谢谢
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* 计算并记录请求的响应时间到日志文件
*/
public class ResponseTimeFilter implements Filter {
protected FilterConfig config;
public void init(FilterConfig filterConfig) throws ServletException {
this.config = filterConfig;
}
// 需要重点实现的方法
public void doFilter(
ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// 响应开始时间
long startTime = System.currentTimeMillis();
// 将请求转发给过滤器链上其他对象
chain.doFilter(request, response);
// 计算请求的响应时间
long elapsed = System.currentTimeMillis() - startTime;
String name = "default";
if (request instanceof HttpServletRequest) {
name = ((HttpServletRequest) request).getRequestURI();
}
// 将请求的响应时间记录到日志文件
config.getServletContext().log(name + " took " + elapsed + " ms");
}
public void destroy() {
}
}
wed.xml配置信息如下
<filter>
<filter-name>RseponseTimeFilter</filter-name>
<filter-class>ch16.RseponseTimeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RseponseTimeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
启动tomcat是出现如下错误信息
严重: Error filterStart
2007-11-16 10:01:34 org.apache.catalina.core.StandardContext start
严重: Context [/serlet] startup failed due to previous errors
请高手看看.原因是什么.谢谢