Я устанавливаю атрибут запроса в переопределенном методе doFilterInternal(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, FilterChain filterChain)
класса OncePerRequestFilter
, но мне не удается получить атрибут запроса в моем сервисе.
public class AuthenticationFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, FilterChain filterChain)
throws ServletException, IOException {
....
.....
httpServletRequest.setAttribute("testing","testing");
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
}
@RequestMapping(
value = "/index/{index:.+}",
method = RequestMethod.GET,
produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<RestApiModelResponse> getIndex(
@PathVariable String index,
HttpServletRequest httpServletRequest)
throws Exception {
var test = httpServletRequest.getAttribute("testing");
}
Здесь я получаю нулевое значение в тестовой переменной..