programmatically retrieve security constraints from web.xml
问题 Is there any possiblity to obtain the list of constraints from web.xml ? <security-constraint> <web-resource-collection> <web-resource-name>admin</web-resource-name> <url-pattern>/admin/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>admin</role-name> </auth-constraint> </security-constraint> Even better is there a programmatic way to add new constraints ? Thanks, Victor 回答1: If you have a ServletContainerInitializer , in its onStartup() method, you would basically do