我请求的路径是:
localhost:8080/companies/12/accounts/35
Run Code Online (Sandbox Code Playgroud)
我的 Rest Controller 包含此功能,我想在 Filter 中获取 companyId 和 accountId。
@RequestMapping(value = "/companies/{companyId}/accounts/{accountId}", method = RequestMethod.PUT)
public Response editCompanyAccount(@PathVariable("companyId") long companyId, @PathVariable("accountId") long accountId,
@RequestBody @Validated CompanyAccountDto companyAccountDto,
HttpServletRequest req) throws ErrorException, InvalidKeySpecException, NoSuchAlgorithmException
Run Code Online (Sandbox Code Playgroud)
是否有任何功能可用于在过滤器内接收此信息?
Map pathVariables = (Map) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
String companyId = (String)pathVariables.get("companyId");
String accountId= (String)pathVariables.get("accountId");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6217 次 |
| 最近记录: |