java.lang.Object | |||||
↳ | org.springframework.context.support.ApplicationObjectSupport | ||||
↳ | org.springframework.web.context.support.WebApplicationObjectSupport | ||||
↳ | org.springframework.web.servlet.support.WebContentGenerator | ||||
↳ | org.springframework.web.servlet.mvc.AbstractController | ||||
↳ | org.springframework.web.servlet.mvc.ServletWrappingController |
Spring Controller implementation that wraps a servlet instance which it manages
internally. Such a wrapped servlet is not known outside of this controller;
its entire lifecycle is covered here (in contrast to ServletForwardingController
).
Useful to invoke an existing servlet via Spring's dispatching infrastructure, for example to apply Spring HandlerInterceptors to its requests.
Note that Struts has a special requirement in that it parses web.xml
to find its servlet mapping. Therefore, you need to specify the DispatcherServlet's
servlet name as "servletName" on this controller, so that Struts finds the
DispatcherServlet's mapping (thinking that it refers to the ActionServlet).
Example: a DispatcherServlet XML context, forwarding "*.do" to the Struts ActionServlet wrapped by a ServletWrappingController. All such requests will go through the configured HandlerInterceptor chain (e.g. an OpenSessionInViewInterceptor). From the Struts point of view, everything will work as usual.
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <ref bean="openSessionInViewInterceptor"/> </list> </property> <property name="mappings"> <props> <prop key="*.do">strutsWrappingController</prop> </props> </property> </bean> <bean id="strutsWrappingController" class="org.springframework.web.servlet.mvc.ServletWrappingController"> <property name="servletClass"> <value>org.apache.struts.action.ActionServlet</value> </property> <property name="servletName"> <value>action</value> </property> <property name="initParameters"> <props> <prop key="config">/WEB-INF/struts-config.xml</prop> </props> </property> </bean>
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.support.WebContentGenerator
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Initialize the wrapped Servlet instance.
| |||||||||||
Destroy the wrapped Servlet instance.
| |||||||||||
Set the name of the bean in the bean factory that created this bean.
| |||||||||||
Specify init parameters for the servlet to wrap,
as name-value pairs.
| |||||||||||
Set the class of the servlet to wrap.
| |||||||||||
Set the name of the servlet to wrap.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoke the the wrapped Servlet instance.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.mvc.AbstractController
| |||||||||||
From class
org.springframework.web.servlet.support.WebContentGenerator
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.DisposableBean
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.mvc.Controller
|
Set the name of the bean in the bean factory that created this bean.
Invoked after population of normal bean properties but before an
init callback such as afterPropertiesSet()
or a custom init-method.
name | the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired. |
---|
Specify init parameters for the servlet to wrap, as name-value pairs.
Set the class of the servlet to wrap.
Needs to implement javax.servlet.Servlet
.
Set the name of the servlet to wrap. Default is the bean name of this controller.
Invoke the the wrapped Servlet instance.
Exception |
---|