jakarta.servlet.http.HttpServlet which treats
its config parameters (init-param entries within the
servlet tag in web.xml) as bean properties.
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
org. 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
org.).
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.
addRequiredProperty, initServletBean, doGet, doPost
| Modifier and Type | Class and Description |
|---|---|
| private static class | HttpServletBean.
PropertyValues implementation created from ServletConfig init parameters. |
| Modifier and Type | Field and Description |
|---|---|
| private ConfigurableEnvironment | |
| protected final Log | logger
Logger available to subclasses. |
| private final Set |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | addRequiredProperty(String
name of the required property property)Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter. |
| protected ConfigurableEnvironment | |
| public ConfigurableEnvironment | getEnvironment()
Implements org. Return the |
| public String | getServletName()
Overrides jakarta. Implements jakarta. Overridden method that simply returns |
| public final void | init()
Overrides jakarta. Map config parameters onto bean properties of this servlet, and invoke subclass initialization. |
| protected void | initBeanWrapper(BeanWrapper
the BeanWrapper to initialize bw)Initialize the BeanWrapper for this HttpServletBean, possibly with custom editors. |
| protected void | |
| public void | setEnvironment(Environment environment)
Implements org. Set the Any environment set here overrides the |
| environment | back to summary |
|---|---|
| private ConfigurableEnvironment environment
| |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. | |
| requiredProperties | back to summary |
|---|---|
| private final Set<String> requiredProperties | |
| HttpServletBean | back to summary |
|---|---|
| public HttpServletBean() | |
| addRequiredProperty | back to summary |
|---|---|
| protected final void addRequiredProperty(String property) Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter. This should be called from the constructor of a subclass. This method is only relevant in case of traditional initialization driven by a ServletConfig instance.
| |
| createEnvironment | back to summary |
|---|---|
| protected ConfigurableEnvironment createEnvironment() Create and return a new Subclasses may override this in order to configure the environment or specialize the environment type returned. | |
| getEnvironment | back to summary |
|---|---|
| public ConfigurableEnvironment getEnvironment() Implements org. Return the If none specified, a default environment will be initialized via
| |
| getServletName | back to summary |
|---|---|
| public String getServletName() Overrides jakarta. Implements jakarta. Overridden method that simply returns
| |
| init | back to summary |
|---|---|
| public final void init() throws ServletException Overrides jakarta. Map config parameters onto bean properties of this servlet, and invoke subclass initialization.
| |
| initBeanWrapper | back to summary |
|---|---|
| protected void initBeanWrapper(BeanWrapper bw) throws BeansException Initialize the BeanWrapper for this HttpServletBean, possibly with custom editors. This default implementation is empty.
| |
| initServletBean | back to summary |
|---|---|
| protected void initServletBean() throws ServletException Subclasses may override this to perform custom initialization. All bean properties of this servlet will have been set before this method is invoked. This default implementation is empty.
| |
| setEnvironment | back to summary |
|---|---|
| public void setEnvironment(Environment environment) Implements org. Set the Any environment set here overrides the
| |
| Access | Constructor and Description |
|---|---|
| public | ServletConfigPropertyValues(ServletConfig
the ServletConfig we'll use to take PropertyValues from config, Set<String> set of property names we need, where
we can't accept default values requiredProperties)Create new ServletConfigPropertyValues. |
| ServletConfigPropertyValues | back to summary |
|---|---|
| public ServletConfigPropertyValues(ServletConfig config, Set<String> requiredProperties) throws ServletException Create new ServletConfigPropertyValues.
| |