Is it possible to add to the available parameters of a request (HttpServletRequest)

前端 未结 6 1695
天涯浪人
天涯浪人 2020-12-14 22:50

I want to intercept a request in a filter/servlet and add a few parameters to it. However, the request does not expose a \'setParameter\' method and the parameter map when m

6条回答
  •  半阙折子戏
    2020-12-14 23:42

    Subclass HttpServletRequestWrapper and override the getParameter methods. The description of this class reads:

    Provides a convenient implementation of the HttpServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet.

    In the filter, wrap the request in an instance of your subclass.

提交回复
热议问题