【发布时间】:2019-12-17 22:51:00
【问题描述】:
我有这段代码,我想在 id == 1 时转发到另一条路径
get("/courses/{id}"){
val id = call.parameters["id"]?.toInt()
if (id is Int) {
if (id == 1)
// i want redirection to "/courses/top"
}
}
【问题讨论】:
我有这段代码,我想在 id == 1 时转发到另一条路径
get("/courses/{id}"){
val id = call.parameters["id"]?.toInt()
if (id is Int) {
if (id == 1)
// i want redirection to "/courses/top"
}
}
【问题讨论】:
你可以使用call.respondRedirect:
if (call.parameters["id"]?.toIntOrNull() == 1) {
call.respondRedirect("/courses/top")
}
【讨论】: