Open youngxhui opened 5 years ago
1.1.2
netty
jvm 1.8 os windows 10 kotlin 1.3.20
I use html dsl create form, but it can not find the action url this is code
Application.kt
@KtorExperimentalLocationsAPI @Location("/user") class User { @Location("/login") data class UserLogin(val username: String, val password: String) @Location("/register") data class UserRegister(val username: String, val password: String) } fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args) @KtorExperimentalLocationsAPI @Suppress("unused") // Referenced in application.conf @kotlin.jvm.JvmOverloads fun Application.module(testing: Boolean = false) { install(Locations) routing { user() get("/") { call.respondHtml { head { title { +"Ktor 入门" } } body { a { href = "/register" +"注册" } form("/user/login", method = FormMethod.post, encType = FormEncType.multipartFormData) { input { type = InputType.text name = "username" } br input { type = InputType.password value = "" name = "password" } br input { type = InputType.submit value = "login" } } } } } get("/login") { call.respond("success") } } }
@KtorExperimentalLocationsAPI fun Route.user() { post<User.UserLogin> { call.respondText("登录成功") } post<User.UserRegister> { user -> run { call.respondText("用户 ${user.username} ${user.password}") } } }
in browers ,can not find the url
but i used the .http file , can get response
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Ktor Version
1.1.2
Ktor Engine Used(client or server and name)
netty
JVM Version, Operating System and Relevant Context
jvm 1.8 os windows 10 kotlin 1.3.20
Feedback
I use html dsl create form, but it can not find the action url this is code
Application.kt
in browers ,can not find the url
but i used the .http file , can get response