Why does a forwarded request pass through filter chain again?

☆樱花仙子☆ 提交于 2019-12-23 15:31:05

问题


I implemented not usual architecture for Grails app because I made front controller which only forwards requests further (based on some criteria). I also implemented locale resolver as a http servlet request filter. And it turned out that forwarded request passes again through filter chain. So flow looks like this:

  1. A request arrives to grails app
  2. The request passes through my filter
  3. The front controller gets the request and forwards it further
  4. The forwarded request passes again through my filter
  5. A back controller gets the request

In the mean time of writing this post I've come up how to omit the problem (my implementation specific). But still I'm curious why does it happen? Forward should work behind the scene. Java EE spec doesn't say anything about this behaviour (forward javadoc).


回答1:


In the <filter-mapping> element there is the forward <dispatcher> option. It includes FORWARD. You'd have to list the options you want the filter to be applied to (request, error, include) and leave out forward.



来源:https://stackoverflow.com/questions/6677631/why-does-a-forwarded-request-pass-through-filter-chain-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!