api上不是有嘛,看看源码,采用的好像是适配器模式 public class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponseProvides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.
API DOC中的东西,我看过N遍了!!!!它只是说出有什么用,我想知道的是它是怎么与容器通信的:(这种逻辑真烦人。像javabean的属性可以从request自动匹配,我倒能理解。
http://www-900.ibm.com/developerWorks/cn/java/j-tomcat/index.shtml其中有这样一段话:
我们定制的包装响应能方便地从帮助类 HttpServletResponseWrapper 中导出。这一类粗略地执行许多方法,允许我们简单地覆盖 getOutputStream() 方法以及 getWriter() 方法,提供定制输出流的实例。我也看过上面这段话,只不知其具体是怎样实现的,
“接口”这种东西的主要用途,就是为了实现外部访问某些类中定制的对象,而提供方便吗?
public class HttpServletResponseWrapper extends ServletResponseWrapper
implements HttpServletResponseProvides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.