我在控制器中有一个方法
@PostMapping("/process")
suspend fun process(
@RequestParam("id") id: String,
@RequestParam("names") names: List<String>,
@RequestParam("repositoryUri") repositoryUri: String
) = coroutineScope {
...
}
我想从前端桌面应用程序发送查询查询,然后尝试
val post = HttpPost(uri)
val builder: MultipartEntityBuilder = MultipartEntityBuilder.create()
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
builder.addTextBody("id", id, ContentType.DEFAULT_BINARY) // id is String, that is Ok
builder.addTextBody("names", names, ContentType.DEFAULT_BINARY) // names is List<String>, error
builder.addTextBody("repositoryUri", repositoryUri, ContentType.DEFAULT_BINARY) // Ok
val entity: HttpEntity = builder.build()
post.entity = entity
httpclient.execute(post)
But the second param in the controller method (names
) is not a string.
The builder has only methods addTextBody and addBinaryBody (but it doesn't seem to fit)
我该怎么做?
附言我用apache