doFilter called twice, intended behaviour?

后端 未结 8 1638
孤街浪徒
孤街浪徒 2021-02-19 16:42

I\'m working through the Java EE servlet tutorial and tried the mood example. I noticed the doFilter is getting called twice, once the servlet call is in the chain and the secon

8条回答
  •  不知归路
    2021-02-19 17:04

    As Mohan has stated, @Component will make your filter be called twice if you have it already registered in you Application class, like this:

    resources.add(new MyFilter());
    

    If that's the case you have to choose between annotating it or registering it. But this is only valid for JAX-RS applications that use Spring. Not the topic of this question.

提交回复
热议问题