Есть GET http://localhost:8088/property/123
или
Есть GET http://localhost:8088/gaz-mas/1722
REST @GetMapping("/property/{id}")
Сделал фильтр который должен проверить в БД есть ли такой id
, прежде чем пропустить дальше.
@WebFilter(filterName = "SecurityRestFilter", urlPatterns = "/property")
public class SecurityRestFilter implements Filter {
@Autowired
PropertyService propertyService;
private final Logger log = LoggerFactory.getLogger(SecurityRestFilter.class);
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws ServletException, IOException {
HttpServletResponse response = (HttpServletResponse) servletResponse;
Long id = (Long) servletRequest.getAttribute("id");
String login = SecurityUtils.getCurrentUserLogin();
if (!propertyService.getPropertyByIdAndPersonalAccount(id, login)) {
response.sendRedirect("/pageNotFound404");
}
chain.doFilter(servletRequest, servletResponse);
}
public void init(FilterConfig config) throws ServletException {
log.debug("Init SecurityRestFilter");
}
}
Проблема заключается в том, что не получается взять этот id
из реста
(property?id=123
- такой вариант знаю, но я не могу изменить передачу id
в ресте)
знаю что можно еще задать типа в input id = "id"
, а в фильтре request.getAttribute("id")
но тоже менять формы и добавлять айдишники не желательно
Подскажите, пожалуйста, каким образом можно получить id
?