title: How to update header parameter and sent the same to Controller using AOP in Spring/Spring boot
body: <p>How to update header parameter and sent the same to Controller using AOP in Spring/Spring boot? I am able to add but not able to send it to the controller. I am getting null value in the controller. I don't want to use @Around.</p>
  
  <pre><code>  @Before("PointcutDefinition.controllerLayer()")
    public Object beforeAdvice(JoinPoint joinPoint)
    {
      HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
      request.setAttribute("traceId", ServiceUtil.getTraceId());
      return request;
    }
  </code></pre>
  
  <p>Update:</p>
  
  <p>I was able to update traceId using the following code.</p>
  
  <pre><code>  @Around("execution(* com.test.api.*.*(..)) &amp;&amp; " + "args(traceId,..)")
    public Object setTraceId(ProceedingJoinPoint joinPoint, String traceId) throws Throwable
    {
      String newTraceId = ServiceUtil.getTraceId();
      Object result = joinPoint.proceed(new Object[]
      { newTraceId, "", "", "", "", "", "", "", "", "" });
      return result;
    }
  </code></pre>
  
  <p>In my Controller, I have multiple methods with a different number of arguments. But the first argument in all the method is traceId. I would like to update traceId alone and leave the other parameter as it is. But in the above approach, I am compelled to pass all the arguments. Is there a way I can update the first param alone and send the remaining parameters untouched.  </p>