「Kotlin」@RequestParamアノテーションのサンプル

構文
fun 関数名(@RequestParam(“パラメータ名") パラメータ名: データ型, model: Model): String
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@Controller
@RequestMapping("/users")
class ReguserForm {
// some code
@GetMapping
fun setupForm(@RequestParam("userId") userId: Int, model: Model): String {
val user = this.clinic.loaduser(userId);
model["user"] = user
return "userForm"
}
}
@Controller @RequestMapping("/users") class ReguserForm { // some code @GetMapping fun setupForm(@RequestParam("userId") userId: Int, model: Model): String { val user = this.clinic.loaduser(userId); model["user"] = user return "userForm" } }
@Controller
@RequestMapping("/users")
class ReguserForm {

    // some code

    @GetMapping
    fun setupForm(@RequestParam("userId") userId: Int, model: Model): String { 
        val user = this.clinic.loaduser(userId);
        model["user"] = user
        return "userForm"
    }


}

 

IT

Posted by arkgame