spring 休息端点中的表单数据
Form-data in spring rest endpoint
如何创建 http POST 端点来发送 spring 中的图片等数据?
我检查了不同的选项并使用了它,但我无法创建它。
例如我使用:
@Controller
@RequiredArgsConstructor
@RequestMapping("/web")
public class AuthenticationController {
@PostMapping(value = "/login", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void login(@RequestParam(value = "username") String userName,
@RequestParam(value = "password") String password) {
// NOP
}
}
你可以这样使用
@PostMapping(value = "/login")
public void login(@RequestParam("document") MultipartFile 文档){
enter code here
}
如何创建 http POST 端点来发送 spring 中的图片等数据?
我检查了不同的选项并使用了它,但我无法创建它。
例如我使用:
@Controller
@RequiredArgsConstructor
@RequestMapping("/web")
public class AuthenticationController {
@PostMapping(value = "/login", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void login(@RequestParam(value = "username") String userName,
@RequestParam(value = "password") String password) {
// NOP
}
}
你可以这样使用
@PostMapping(value = "/login")
public void login(@RequestParam("document") MultipartFile 文档){
enter code here
}