Inject `@PathVariable` into a request scoped bean

Keywords: java spring-mvc scope request


I want to propagate some path variables as a part of request scoped bean. I want this bean to be immutable, and I don't want to parse the path manually and depend on javax.servlet stuff

Now I see the solution with setting up Provider<MyPathVariables> in the @ControllerAdvice But I don't like making MyPathVariables mutable.

Another option is injecting HttpServletRequest into my bean constructor and manually parsing the path, and I also don't like this double working, and especially I don't like dependency to javax.servlet in my beautiful spring app.

Is there another option?