Home > Software design >  Form-data in spring rest endpoint
Form-data in spring rest endpoint

Time:03-04

How can I create http POST endpoint to send data like pictures in spring?

I checked different options and used its but I can not create it.

For example I used:

@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
   }
 }

enter image description here

CodePudding user response:

You can use like this

@PostMapping(value = "/login") public void login(@RequestParam("document") MultipartFile document) { enter code here }

  • Related