类 ServletForwardingController
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.context.ApplicationContextAware,Controller,HttpRequestHandler,ServletContextAware
Useful to invoke an existing servlet via Framework's dispatching infrastructure, for example to apply Framework HandlerInterceptors to its requests. This will work even in a minimal Servlet container that does not support Servlet filters.
Example: web.xml, mapping all "/myservlet" requests to a Framework dispatcher. Also defines a custom "myServlet", but without servlet mapping.
<servlet> <servlet-name>myServlet</servlet-name> <servlet-class>mypackage.TestServlet</servlet-class> </servlet> <servlet> <servlet-name>myDispatcher</servlet-name> <servlet-class>cn.taketoday.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>myDispatcher</servlet-name> <url-pattern>/myservlet</url-pattern> </servlet-mapping>Example: myDispatcher-servlet.xml, in turn forwarding "/myservlet" to your servlet (identified by servlet name). All such requests will go through the configured HandlerInterceptor chain (e.g. an OpenSessionInViewInterceptor). From the servlet point of view, everything will work as usual.
<bean id="myServletForwardingController" class="cn.taketoday.web.servlet.mvc.ServletForwardingController"> <property name="servletName"><value>myServlet</value></property> </bean>
- 从以下版本开始:
- 4.0 2022/2/8 17:18
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
字段从类继承的字段 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 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected ModelAndViewhandleRequestInternal(RequestContext request) Template method.voidsetBeanName(String name) voidsetServletContext(ServletContext servletContext) Set theServletContextthat this object runs in.voidsetServletName(String servletName) Set the name of the servlet to forward to, i.e. the "servlet-name" of the target servlet in web.xml.protected booleanuseInclude(HttpServletRequest request, HttpServletResponse response) Determine whether to use RequestDispatcher'sincludeorforwardmethod.从类继承的方法 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
-
字段详细资料
-
servletName
-
beanName
-
servletContext
-
-
构造器详细资料
-
ServletForwardingController
public ServletForwardingController()
-
-
方法详细资料
-
setServletName
Set the name of the servlet to forward to, i.e. the "servlet-name" of the target servlet in web.xml.Default is the bean name of this controller.
-
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
-
setBeanName
- 指定者:
setBeanName在接口中cn.taketoday.beans.factory.BeanNameAware
-
handleRequestInternal
从类复制的说明:AbstractControllerTemplate method. Subclasses must implement this. The contract is the same as forhandleRequest. -
useInclude
Determine whether to use RequestDispatcher'sincludeorforwardmethod.Performs a check whether an include URI attribute is found in the request, indicating an include request, and whether the response has already been committed. In both cases, an include will be performed, as a forward is not possible anymore.
- 参数:
request- current HTTP requestresponse- current HTTP response- 返回:
truefor include,falsefor forward- 另请参阅:
-