FilterMappingType filterMapping = webApp.addNewFilterMapping();
filterMapping.addNewFilterName().setStringValue(filterName);
for (String servletName : webFilter.servletNames()) {
filterMapping.addNewServletName().setStringValue(servletName);
}
for (DispatcherType dispatcherType : webFilter.dispatcherTypes()) {
filterMapping.addNewDispatcher().setStringValue(dispatcherType.name());
}
for (String urlPattern : urlPatterns) {
filterMapping.addNewUrlPattern().setStringValue(urlPattern);
}