我想在过滤器里返回代理后的servletrequest,发现其底层是tomcat的catlina包下的RequestFacade类,所以准备对它用cglib进行代理,增强其方法,此时发现对servletrequest强类转为RequestFacade时,报异常:
org.apache.catalina.connector.RequestFacade cannot cast to org.apache.catalina.connector.RequestFacade
RequestFacade这个类的包我是在lib中放入了tomcat/lib下的catlina.jar后才有的,这个包应该就是tomcat使用的包,请问问题出在哪里呢?~~
public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterchain)
throws IOException, ServletException {
//此处发生类型转换异常
RequestFacade request = (RequestFacade)servletrequest;
HttpServletResponse response = (HttpServletResponse)servletresponse;
HttpServletRequest newrequest=new CGLibProxy(request).createProxy();
String testString = newrequest.getRequestURL().toString();
System.out.println(testString);
filterchain.doFilter(newrequest, response);
}