@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 註解。 |