1
zj
2025-08-02 c353a3666b23f0d5c3f341b3d5d9626c7892f68e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.nq.security.xss;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.web.method.HandlerMethod;
 
import org.springframework.web.servlet.DispatcherServlet;
 
import org.springframework.web.servlet.HandlerExecutionChain;
 
public class DispatcherServletWrapper extends DispatcherServlet {
 
    protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
        HandlerExecutionChain chain = super.getHandler(request);
        Object handler = chain.getHandler();
        if (!(handler instanceof HandlerMethod)) {
            return chain;
        }
        HandlerMethod hm = (HandlerMethod) handler;
        if (!hm.getBeanType().isAnnotationPresent(org.springframework.stereotype.Controller.class)) {
            return chain;
        }
        return new HandlerExecutionChainWrapper(chain, request, getWebApplicationContext());
    }
}