0
에서 작동하지 않습니다 :initParams 내가 봄 부팅에 의해 생성 된 자바 웹 프로젝트에 다음과 같은 주석을 사용하여 필터를 만든 웹 필터 주석
@Order(2)
@Component
@WebFilter(
filterName = "jwtFitler",
urlPatterns = "/*",
initParams = { @WebInitParam(name = "excludedPaths", value = "login, hello") }
)
그러나, initParams이 작동하지 않는, excludedPaths 및 excludedUrls는 항상 null입니다. 아무도 왜 저에게 말해 줄 수 있습니까?
public class MyFilter implements Filter {
private String[] excludedUrls;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
String excludedPaths = filterConfig.getInitParameter("excludedPaths");
System.out.println("excludedPaths:" + excludedPaths);
if(!StringUtils.isEmpty(excludedPaths))
excludedUrls = excludedPaths.split(",");
System.out.println("excludedUrls:" + excludedUrls);
}
//......
}
고마워 :), 그것은 Compoent 주석을 제거하고 ServletComponentScan 주석을 추가 한 후에 작동합니다. 그러나 주문 주석은 작동하지 않습니다. –
실제로. 순서가 중요하다면'@ ServletComponentScan'과'@WebFilter' 대신'FilterRegistrationBean'을 사용해야 할 것입니다. –
FilterRegistrationBean을 사용하고 있으며 모든 것이 예상대로 작동합니다. 도와 줘서 고마워, 앤디. :) –