Home > Java > javaTutorial > body text

Example explanation of HandlerExecutionChain class

零下一度
Release: 2017-07-18 14:37:20
Original
1838 people have browsed it

Before explaining HandlerExecutionChain, let’s have a general understanding of the core development steps of SpringMVC:

Deploy DispaterServlet in web.xml, and configure springmvc.xml and other files;

Request the mapping file to Processor HandlerMapping;

HandlerMapping will map the request to a handler object of type HandlerExecutionChain;

Pass the handler object as a parameter to the instantiation object of HandlerAdapter, and calling its handler method will generate a ModelAndView object ;

Use the ViewResolver view parser to parse the ModelAndView generated in the previous step into a View;

DispatcherServlet returns the view to the user based on the obtained View.

The HandlerExecutionChain class is relatively simple and easy to understand.

============================================== ============================

  HandlerExecutionChain {
Copy after login

========= ================================================== =============

The following are some attributes of the class.

  List<HandlerInterceptor>
Copy after login

================================== =========================================

 applyPreHandle(HttpServletRequest request, HttpServletResponse response) = (! ( i = 0; i < interceptors.length; i++= (!interceptor.preHandle(request, response,  .interceptorIndex =
Copy after login

========================================== ================================

 applyPostHandle(HttpServletRequest request, HttpServletResponse response, ModelAndView mv) = (! ( i = interceptors.length - 1; i >= 0; i--=
Copy after login
    /** * 这个方法只会执行preHandle()方法已经成功执行并且返回true的拦截器中的postHandle()方法。     */void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, Exception ex)throws Exception {

        HandlerInterceptor[] interceptors = getInterceptors();if (!ObjectUtils.isEmpty(interceptors)) {for (int i = this.interceptorIndex; i >= 0; i--) {
                HandlerInterceptor interceptor = interceptors[i];try {
                    interceptor.afterCompletion(request, response, this.handler, ex);
                }catch (Throwable ex2) {
                    logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
                }
            }
        }
    }
Copy after login

The above is the detailed content of Example explanation of HandlerExecutionChain class. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!