HttpServletBean

HttpServletBean
public abstract class HttpServletBean
   
   
   
   
extends HttpServlet
		

Simple extension of HttpServlet which treats its config parameters (init-param entries within the servlet tag in web.xml) as bean properties.

HttpServlet的简单扩展用来处理 (init-param)in the web.xml
A handy superclass for any type of servlet. Type conversion of config parameters is automatic, with the corresponding setter method getting invoked with the converted value. It is also possible for subclasses to specify required properties. Parameters without matching bean property setter will simply be ignored.

This servlet leaves request handling to subclasses, inheriting the default behavior of HttpServlet (doGet, doPost, etc).

This generic servlet base class has no dependency on the Spring ApplicationContext concept. Simple servlets usually don't load their own context but rather access service beans from the Spring root application context, accessible via the filter's ServletContext (see WebApplicationContextUtils).

The FrameworkServlet class is a more specific servlet base class which loads its own application context. FrameworkServlet serves as direct base class of Spring's full-fledged DispatcherServlet.

public abstract class FrameworkServlet
   
   
   
   
extends HttpServletBean
implements ApplicationListener
		

Base servlet for Spring's web framework. Provides integration with a Spring application context, in a JavaBean-based overall solution.

spring web Framework的基础 servlet  ,提供在以javabean为基础的整体解决方案已完成与spring应用上下文的集成
This class offers the following functionality:
1.管理一个servlet一个网络应用上下文实例,这个servlet的配置由servlet命名空间里的bean来决定
2.根据请求处理发布事件,是否请求成功的被处理了

  • Manages a WebApplicationContext instance per servlet. The servlet's configuration is determined by beans in the servlet's namespace.
  • Publishes events on request processing, whether or not a request is successfully handled.

Subclasses must implement doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) to handle requests. Because this extends HttpServletBean rather than HttpServlet directly, bean properties are automatically mapped onto it. Subclasses can override initFrameworkServlet() for custom initialization.

因为它继承自httpservletBean 所以bean的属性已经被自动的装配了,子类可以通过覆盖initFrameworkServlet来定制初始化bean

Detects a "contextClass" parameter at the servlet init-param level, falling back to the default context class, XmlWebApplicationContext, if not found. Note that, with the default FrameworkServlet, a custom context class needs to implement the ConfigurableWebApplicationContext SPI.

Passes a "contextConfigLocation" servlet init-param to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, like "test-servlet.xml, myServlet.xml". If not explicitly specified, the context implementation is supposed to build a default location from the namespace of the servlet.

Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files, at least when using Spring's default ApplicationContext implementation. This can be leveraged to deliberately override certain bean definitions via an extra XML file.

The default namespace is "'servlet-name'-servlet", e.g. "test-servlet" for a servlet-name "test" (leading to a "/WEB-INF/test-servlet.xml" default location with XmlWebApplicationContext). The namespace can also be set explicitly via the "namespace" servlet init-param.



大盘预测

你可能感兴趣的:(HttpServletBean)