Class Overview
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>
Summary
[Expand]
Inherited Methods |
From class
org.springframework.web.servlet.mvc.AbstractController
ModelAndView
|
handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the request and return a ModelAndView object which the DispatcherServlet
will render.
|
abstract
ModelAndView
|
handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
Template method.
|
final
boolean
|
isSynchronizeOnSession()
Return whether controller execution should be synchronized on the session.
|
final
void
|
setSynchronizeOnSession(boolean synchronizeOnSession)
Set if controller execution should be synchronized on the session,
to serialize parallel invocations from the same client.
|
|
From class
org.springframework.web.servlet.support.WebContentGenerator
final
void
|
applyCacheSeconds(HttpServletResponse response, int seconds, boolean mustRevalidate)
Apply the given cache seconds and generate respective HTTP headers.
|
final
void
|
applyCacheSeconds(HttpServletResponse response, int seconds)
Apply the given cache seconds and generate corresponding HTTP headers,
i.e.
|
final
void
|
cacheForSeconds(HttpServletResponse response, int seconds, boolean mustRevalidate)
Set HTTP headers to allow caching for the given number of seconds.
|
final
void
|
cacheForSeconds(HttpServletResponse response, int seconds)
Set HTTP headers to allow caching for the given number of seconds.
|
final
void
|
checkAndPrepare(HttpServletRequest request, HttpServletResponse response, int cacheSeconds, boolean lastModified)
Check and prepare the given request and response according to the settings
of this generator.
|
final
void
|
checkAndPrepare(HttpServletRequest request, HttpServletResponse response, boolean lastModified)
Check and prepare the given request and response according to the settings
of this generator.
|
final
int
|
getCacheSeconds()
Return the number of seconds that content is cached.
|
final
String[]
|
getSupportedMethods()
Return the HTTP methods that this content generator supports.
|
final
boolean
|
isRequireSession()
Return whether a session is required to handle requests.
|
final
boolean
|
isUseCacheControlHeader()
Return whether the HTTP 1.1 cache-control header is used.
|
final
boolean
|
isUseCacheControlNoStore()
Return whether the HTTP 1.1 cache-control header value "no-store" is used.
|
final
boolean
|
isUseExpiresHeader()
Return whether the HTTP 1.0 expires header is used.
|
final
void
|
preventCaching(HttpServletResponse response)
Prevent the response from being cached.
|
final
void
|
setCacheSeconds(int seconds)
Cache content for the given number of seconds.
|
final
void
|
setRequireSession(boolean requireSession)
Set whether a session should be required to handle requests.
|
final
void
|
setSupportedMethods(String[] methods)
Set the HTTP methods that this content generator should support.
|
final
void
|
setUseCacheControlHeader(boolean useCacheControlHeader)
Set whether to use the HTTP 1.1 cache-control header.
|
final
void
|
setUseCacheControlNoStore(boolean useCacheControlNoStore)
Set whether to use the HTTP 1.1 cache-control header value "no-store"
when preventing caching.
|
final
void
|
setUseExpiresHeader(boolean useExpiresHeader)
Set whether to use the HTTP 1.0 expires header.
|
|
From class
org.springframework.web.context.support.WebApplicationObjectSupport
|
From class
org.springframework.context.support.ApplicationObjectSupport
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.springframework.beans.factory.BeanNameAware
abstract
void
|
setBeanName(String name)
Set the name of the bean in the bean factory that created this bean.
|
|
From interface
org.springframework.beans.factory.DisposableBean
abstract
void
|
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
|
From interface
org.springframework.beans.factory.InitializingBean
abstract
void
|
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
|
From interface
org.springframework.context.ApplicationContextAware
|
From interface
org.springframework.web.context.ServletContextAware
abstract
void
|
setServletContext(ServletContext servletContext)
Set the ServletContext that this object runs in.
|
|
From interface
org.springframework.web.servlet.mvc.Controller
abstract
ModelAndView
|
handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the request and return a ModelAndView object which the DispatcherServlet
will render.
|
|
Public Constructors
public
ServletWrappingController
()
Public Methods
public
void
afterPropertiesSet
()
Initialize the wrapped Servlet instance.
public
void
destroy
()
Destroy the wrapped Servlet instance.
public
void
setBeanName
(String name)
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.
Parameters
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.
|
public
void
setInitParameters
(Properties initParameters)
Specify init parameters for the servlet to wrap,
as name-value pairs.
public
void
setServletClass
(Class servletClass)
Set the class of the servlet to wrap.
Needs to implement javax.servlet.Servlet
.
public
void
setServletName
(String servletName)
Set the name of the servlet to wrap.
Default is the bean name of this controller.
Protected Methods
protected
ModelAndView
handleRequestInternal
(HttpServletRequest request, HttpServletResponse response)
Invoke the the wrapped Servlet instance.