0

Each request in my app goes through the custom interceptor where it validates the sessionid filed value which is passed as the one of the parameters in the request payload(post method).

If it is url paramter then we can use following snippet to catch the parameter.

 Map<String, Object> parameters =
        actionInvocation.getInvocationContext().getParameters();


    String sessionid = parameters.get("sessionId");

What could be the way to catch this parameter in interceptor if "sessionId" being sent as part request payload. I tired below code snippet to catch in the interceptor and it is working fine but in later stages in action classes body is not available to read.if we read twice then request body is not available for the second time to read.

    public String intercept(ActionInvocation actionInvocation) throws Exception {

        Log.debug(getClass().getName(), "intercept", "Debug enter");
        ActionContext context = actionInvocation.getInvocationContext();
        HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
        RestPostBody restBody= new Gson().fromJson(request.getReader(), RestPostBody.class);

     }
  • If you put your interceptor after the parameters interceptor the params should already be set and accessible. – Dave Newton Jul 09 '19 at 13:16
  • If you read something about json plugin, then read carefully this https://stackoverflow.com/a/27686588/573032 – Roman C Jul 11 '19 at 15:31

0 Answers0