@PostMapping(value = { "/weblogin", "/mobilelogin" })
@ResponseStatus(HttpStatus.OK)
public AccessTokenResponseModel login() { // need to distinguish "/weblogin" or "/mobilelogin" }
在春季启动时,如何区分邮件请求来自“/ weblogin”或“/ mobilelogin” 在login()方法?
答案 0 :(得分:2)
您可以使用BEST_MATCHING_PATTERN_ATTRIBUTE属性。
@PostMapping(value = { "/weblogin", "/mobilelogin" })
@ResponseStatus(HttpStatus.OK)
public AccessTokenResponseModel login(HttpServletRequest httpRequest) {
final String requestMapping = ( String ) httpRequest.getAttribute( HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE );
final boolean isMobileLogin = requestMapping.contains("/mobilelogin");
....
}