cpe
11/04/2019, 9:09 PM<form name="users" action="POST">
<input type="text" name="someInfo">
<input type="text" name="users[name][0]">
<input type="text" name="users[surname][0]">
<input type="text" name="users[name][1]">
<input type="text" name="users[surname][1]">
</form>
data class InputForm(val someInfo: String, val users: Map<String, List<String>)
which could be wired like this:
@PostMapping("/users")
fun updateUsers(inputForm: InputForm) {
// access input form data like "someInfo" and the map "user"
}
With the migration I have something like:
router {
POST("/users", userController::updateUsers)
}
fun updateUsers(request: ServerRequest): ServerResponse {
val inputForm = request.body<InputForm>()
// do some stuff
return ServerResponse.ok().render("success.html")
}
This is causing the following exception: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
What is the correct way to read the message in an automated way like it was possible with the traditional mapping? Or do I need to write a custom HttpMessageConverter?mister11
11/05/2019, 9:06 AMrequest.formData()
instead of request.body()
.cpe
11/05/2019, 9:13 AMcpe
11/05/2019, 9:20 AMDefaultServerRequest
but WebMVC not.sdeleuze
11/05/2019, 9:45 AMrequest.params()
cpe
11/05/2019, 10:09 AMval params: MultiValueMap<String, String> = request.params()
the form data is not converted into the target class. I could write a workaround for parsing the plain parameters to a map, but that was supported out of with the common, non-functional style.sdeleuze
11/05/2019, 11:29 AMsdeleuze
11/05/2019, 1:48 PMcpe
11/05/2019, 4:16 PMsdeleuze
11/05/2019, 4:34 PMrequest.params()
more discoverable.
For your need, I think what you want is data binding which is bot supported on WebFlux and WebMvc functional API. Feel free to create an issue if you care.