简体   繁体   中英

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 在此输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM