public class ServletBeanWrappingController
extends org.springframework.web.servlet.mvc.AbstractController
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
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,
org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor,
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter,
org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor,
org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter| Constructor and Description |
|---|
ServletBeanWrappingController() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Initialize the wrapped Servlet instance.
|
void |
destroy()
Destroy the wrapped Servlet instance.
|
javax.servlet.Servlet |
getServletInstance() |
String |
getServletName() |
protected org.springframework.web.servlet.ModelAndView |
handleRequestInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Invoke the the wrapped Servlet instance.
|
void |
setInitParameters(Properties initParameters)
Specify init parameters for the servlet to wrap,
as name-value pairs.
|
void |
setServletInstance(javax.servlet.Servlet servletInstance) |
void |
setServletName(String servletName)
Set the name of the servlet to wrap.
|
handleRequest, isSynchronizeOnSession, setSynchronizeOnSessionapplyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, checkRequest, getCacheControl, getCacheSeconds, getSupportedMethods, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeadergetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextpublic void setServletName(String servletName)
public void setInitParameters(Properties initParameters)
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionServlet.init(javax.servlet.ServletConfig)protected org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws Exception
handleRequestInternal in class org.springframework.web.servlet.mvc.AbstractControllerExceptionServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)public void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanServlet.destroy()public javax.servlet.Servlet getServletInstance()
public void setServletInstance(javax.servlet.Servlet servletInstance)
public String getServletName()
Copyright © 2026. All rights reserved.