WebStatFilter support exclustions

This commit is contained in:
wenshao
2012-08-12 21:51:01 +08:00
parent 01f6ac4012
commit ac3f8cef2b
2 changed files with 45 additions and 9 deletions
@@ -1,5 +1,6 @@
package com.alibaba.druid.util;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
public class DruidWebUtils {
@@ -18,4 +19,26 @@ public class DruidWebUtils {
return ip;
}
private static String getContextPath_2_5(ServletContext context) {
String contextPath = context.getContextPath();
if (contextPath == null || contextPath.length() == 0) {
contextPath = "/";
}
return contextPath;
}
public static String getContextPath(ServletContext context) {
if (context.getMajorVersion() == 2 && context.getMinorVersion() < 5) {
return null;
}
try {
return getContextPath_2_5(context);
} catch (NoSuchMethodError error) {
return null;
}
}
}