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>
ServletForwardingController
| Modifier and Type | Class and Description |
|---|---|
| private class | ServletWrappingController.
Internal implementation of the ServletConfig interface, to be passed to the wrapped servlet. |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private Properties | |
| private Class | |
| private Servlet | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. Initialize the wrapped Servlet instance. |
| public void | destroy()
Implements org. Destroy the wrapped Servlet instance. |
| protected ModelAndView | handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
Implements abstract org. Invoke the wrapped Servlet instance. |
| public void | setBeanName(String
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 name)BeanFactoryUtils#originalBeanName(String)
method to extract the original bean name (without suffix), if desired.Implements org. Set the name of the bean in the bean factory that created this bean. |
| public void | setInitParameters(Properties initParameters)
Specify init parameters for the servlet to wrap, as name-value pairs. |
| public void | |
| public void |
| beanName | back to summary |
|---|---|
| private String beanName
| |
| initParameters | back to summary |
|---|---|
| private Properties initParameters | |
| servletClass | back to summary |
|---|---|
| private Class<? extends Servlet> servletClass
| |
| servletInstance | back to summary |
|---|---|
| private Servlet servletInstance
| |
| servletName | back to summary |
|---|---|
| private String servletName
| |
| ServletWrappingController | back to summary |
|---|---|
| public ServletWrappingController() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws Exception Implements org. Initialize the wrapped Servlet instance.
| |
| destroy | back to summary |
|---|---|
| public void destroy() Implements org. Destroy the wrapped Servlet instance.
| |
| handleRequestInternal | back to summary |
|---|---|
| protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception Implements abstract org. Invoke the wrapped Servlet instance. | |
| setBeanName | back to summary |
|---|---|
| public void setBeanName(String name) Implements org. Doc from org. 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
| |
| setInitParameters | back to summary |
|---|---|
| public void setInitParameters(Properties initParameters) Specify init parameters for the servlet to wrap, as name-value pairs. | |
| setServletClass | back to summary |
|---|---|
| public void setServletClass(Class<? extends Servlet> servletClass) Set the class of the servlet to wrap.
Needs to implement
| |
| setServletName | back to summary |
|---|---|
| public void setServletName(String servletName) Set the name of the servlet to wrap. Default is the bean name of this controller. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | getInitParameter(String
a paramName)String specifying the name of the initialization parameterImplements jakarta. Returns a |
| public Enumeration | getInitParameterNames()
Implements jakarta. Returns the names of the servlet's initialization parameters as an |
| public ServletContext | getServletContext()
Implements jakarta. Returns a reference to the |
| public String | getServletName()
Implements jakarta. Returns the name of this servlet instance. |
| DelegatingServletConfig | back to summary |
|---|---|
| private DelegatingServletConfig() | |
| getInitParameter | back to summary |
|---|---|
| public String getInitParameter(String paramName) Implements jakarta. Doc from jakarta. Returns a | |
| getInitParameterNames | back to summary |
|---|---|
| public Enumeration Implements jakarta. Doc from jakarta. Returns the names of the servlet's initialization parameters as an
| |
| getServletContext | back to summary |
|---|---|
| public ServletContext getServletContext() Implements jakarta. Doc from jakarta. Returns a reference to the
| |
| getServletName | back to summary |
|---|---|
| public String getServletName() Implements jakarta. Doc from jakarta. Returns the name of this servlet instance. The name may be provided via server administration, assigned in the web application deployment descriptor, or for an unregistered (and thus unnamed) servlet instance it will be the servlet's class name. | |