@RequestAttribute
類似於 @SessionAttribute
,您可以使用 @RequestAttribute
註解來存取先前建立的請求屬性(例如,由 Servlet Filter
或 HandlerInterceptor
建立)。
-
Java
-
Kotlin
@GetMapping("/")
public String handle(@RequestAttribute Client client) { (1)
// ...
}
1 | 使用 @RequestAttribute 註解。 |
@GetMapping("/")
fun handle(@RequestAttribute client: Client): String { (1)
// ...
}
1 | 使用 @RequestAttribute 註解。 |