As @axtavt notes, you cannot do this. That's why (I think) they designed it that way.
To indicate order, annotations will require an additional argument that (somehow) determines the position in the chain; e.g. Order '. There are problems with this:
If the servlet has several filters, the order of which is specified by the annotation parameters, then the programmer / deployer should examine the annotations for all filter classes to determine what the actual order is.
This class of filters can theoretically be used in several servlets, even in several web folders. Each servlet or webapp may require that the order of the filters be different. You cannot achieve this simply by using annotation in the filter class.
If someone deploys the webapp necessary to change the filtering order, he will need to change the source code, recompile and rebuild the WAR file.
I think that the designers considered these problems and decided that the best place to specify the filtering order is in the web.xml file.
Stephen c
source share