You can map filters to a URL or a servlet name. When a filter is mapped to a URL, the filter applies to every servlet and JSP page in your Web application. When a filter is mapped to a servlet name, it applies to a single servlet or JSP.
IntelliJ IDEA provides the facilities to configure, edit, and remove Filter Mapping elements using the Web Module Editor window, Assembly Descriptor tab. The tab is synchronized with the Text tab where the web.xml code is generated based on the settings you specify.
- Select the required filter in the Filters Configured pane, tab General, and switch to the Assembly Descriptor tab.
- In the Filter Mappings pane, click . A new row appears with the Filter text box displaying the name of the selected filter.
- To define a URL-mapping, in the
text box, type the URL pattern that associates the filter with the URLs that call the filter.
A URL pattern may contain a subset of US-ASCII characters. Avoid using other values.
- To define a servlet-mapping, in the Servlet drop-down list select the relevant servlet.
Filters are executed in the order in which they are declared in web.xml. URL-mapped filters are executed before servlet-mapped filters.