Web.xml intellij does not start automatically when adding servlet or filter

When I create a servlet or filter in eclipse, the xml is automatically inserted into the web.xml. But when I do the same in Intellij I need to manually edit the xml file.

When I type the code below in Intellij, I get a "filter must have a mapping" error. But why isn't this generated automatically when I use the code below.

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

      

There should be a very simple answer for this, but I can't figure out why Intellij doesn't auto-complete web.xml and eclipse. Or I need to include some plugin. I can't find a good answer to this?

* Edit these settings in my project enter image description here

+3


source to share


1 answer


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



It won't show up in web.xml

, but it does the trick.

0


source







All Articles