类 ServletWrappingController
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.beans.factory.DisposableBean,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.ApplicationContextAware,Controller,HttpRequestHandler,ServletContextAware
ServletForwardingController).
Useful to invoke an existing servlet via Framework's dispatching infrastructure, for example to apply Framework 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="strutsWrappingController" class="cn.taketoday.web.handler.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>- 从以下版本开始:
- 4.0 2022/2/8 17:18
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private classInternal implementation of the ServletConfig interface, to be passed to the wrapped servlet. -
字段概要
字段修饰符和类型字段说明private Stringprivate Propertiesprivate ServletContextprivate Servletprivate String从类继承的字段 cn.taketoday.web.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.HttpRequestHandler
NONE_RETURN_VALUE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidInitialize the wrapped Servlet instance.voiddestroy()Destroy the wrapped Servlet instance.protected ModelAndViewhandleRequestInternal(RequestContext request) Invoke the wrapped Servlet instance.voidsetBeanName(String name) voidsetInitParameters(Properties initParameters) Specify init parameters for the servlet to wrap, as name-value pairs.voidsetServletClass(Class<? extends Servlet> servletClass) Set the class of the servlet to wrap.voidsetServletContext(ServletContext servletContext) Set theServletContextthat this object runs in.voidsetServletName(String servletName) Set the name of the servlet to wrap.从类继承的方法 cn.taketoday.web.handler.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession从类继承的方法 cn.taketoday.web.WebContentGenerator
applyCacheControl, applyCacheSeconds, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isRequireSession, prepareResponse, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setVaryByRequestHeaders从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
servletClass
-
servletName
-
initParameters
-
beanName
-
servletInstance
-
servletContext
-
-
构造器详细资料
-
ServletWrappingController
public ServletWrappingController()
-
-
方法详细资料
-
setServletClass
Set the class of the servlet to wrap. Needs to implementjakarta.servlet.Servlet.- 另请参阅:
-
setServletName
Set the name of the servlet to wrap. Default is the bean name of this controller. -
setInitParameters
Specify init parameters for the servlet to wrap, as name-value pairs. -
setBeanName
- 指定者:
setBeanName在接口中cn.taketoday.beans.factory.BeanNameAware
-
afterPropertiesSet
Initialize the wrapped Servlet instance.- 指定者:
afterPropertiesSet在接口中cn.taketoday.beans.factory.InitializingBean- 抛出:
Exception- 另请参阅:
-
handleRequestInternal
Invoke the wrapped Servlet instance. -
destroy
public void destroy()Destroy the wrapped Servlet instance.- 指定者:
destroy在接口中cn.taketoday.beans.factory.DisposableBean- 另请参阅:
-
setServletContext
从接口复制的说明:ServletContextAwareSet theServletContextthat this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSetor a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext.- 指定者:
setServletContext在接口中ServletContextAware- 参数:
servletContext- the ServletContext object to be used by this object- 另请参阅:
-
InitializingBean.afterPropertiesSet()ApplicationContextAware.setApplicationContext(cn.taketoday.context.ApplicationContext)
-
getServletContext
-