Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.xml intellij is not auto completing when adding servlet or filter

When i create a servlet or a filter in eclipse the xml code is automatically insert into the web.xml. But when i do the same thing in Intellij i need to manually edit the xml file.

When i type the code below in Intellij i get an error "filter should have mapping" But why is this not automatically created when i use the code below.

<filter>
    <filter-name>TestFilter</filter-name>
    <filter-class>be.demoapp.filters.TestFilter</filter-class>
</filter>

There has to be a very simple answer for this but i can't figure out why Intellij does not auto complete the web.xml and eclipse does. Or do i need to turn on some plugin. I can't find a good answer on this ?

*Edit these are the settings in my project enter image description here

like image 464
Greg Avatar asked Mar 01 '26 01:03

Greg


1 Answers

Inside your class, use the annotation @WebFilter(name = "TestFilter", urlPatterns = "/TestFilter")

It won't show in web.xml but it will do the trick.

like image 69
Marco Altran Avatar answered Mar 02 '26 13:03

Marco Altran