1、转:http://www.jb51.net/article/111531.htm
转:https://blog.****.net/king_is_everyone/article/details/53098350
2、BUG:
Whitelabel Error Page
3、分析:
Web中有个拦截校验token的Filter拦截了所有head==null 的请求导致。
4、修改Code:
@Slf4j
@Component
public class UmLoginFilter extends WebStatFilter {
@Autowired
private SystemProperties systemProperties;
/*
* <p>Description: </p>
* @param request
* @param response
* @param chain
* @throws IOException
* @throws ServletException
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
String contextPath = req.getContextPath();
String requestURI = req.getRequestURI();
// 请求接口地址
String ur = requestURI.substring(contextPath.length());
try {
String header = req.getHeader(CommConstant.AUTHOR);
if (isInclude(ur)) {
UmLoginFilter.log.warn(" UmLoginFilter =》 登陆 / GET请求 ");
chain.doFilter(req, res);
return;
}
// 无Token请求头 情况下:只允许 直接登录
if (header == null) {
super.doFilter(request, response, chain);
} else if (!header.startsWith(CommConstant.REQ_STRING)) {
UmLoginFilter.log.warn("-----------uri: {}", ur);
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
} else {
/* 此处略*/
return;
}
} catch (Exception e) {
UmLoginFilter.log.error("", e);
try {
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (IOException e1) {
}
return;
}
}
/**
* 是否需要过滤
* @param url
* @return
*/
private boolean isInclude(String url) {
String[] strings = systemProperties.getIgnoreSources().split(",");
List<String> list = Arrays.asList(strings);
for (String str : list) {
if (str.contains(url)) {
return true;
}
}
return false;
}
}
/*
* 登陆用户 Token 校验
* 注册DruidFilter拦截
*/
@Bean
public FilterRegistrationBean loginFilter(UmLoginFilter umLoginFilter) {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(umLoginFilter);
registration.addUrlPatterns("/*");
Map<String, String> initParams = new HashMap<>();
// 设置忽略请求
initParams.put("exclusions", "*.js,*.gif,*.php,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");
registration.setInitParameters(initParams);
registration.setName("umLoginFilter");
return registration;
}
5、运行之后,发现 Druid监控页显示不全,没有数据。。。。。。。。。。。再分析,原来拦截了/favicon.ico
修改:
6、以为没事了,但是。。。。。。。。。。
Mapping [/favicon.ico] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resour
竟然没数据。。。。。
7、又分析了下
转:https://blog.****.net/wdd668/article/details/74643356
问题解决: