1
zj
2026-01-14 af7f754c7eeb82a7ec7570d1396ff91848d83ca7
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());
    }
}