如何从post方法spring中的表单数据值中获取字符串

k4emjkb1  于 2021-07-05  发布在  Java
关注(0)|答案(0)|浏览(199)

我试图在spring的post方法中从表单数据中获取字符串值。
我收到一个错误的请求。

@SuppressWarnings("unchecked")
@RequestMapping(value = "/formdataValueGet", method = RequestMethod.POST, consumes = {"multipart/form-data"})
public ResponseEntity<Map<String, Object>> formdataValueGet(HttpServletRequest request, @RequestParam("file") String file) throws Exception{
    System.out.println("Api hit file upload");
    Map<String, Object> params = new HashMap<String, Object>();
    System.out.println("Map issue");
    try{
    params.put("error", "Failed to make payment");
    return new ResponseEntity<Map<String, Object>>(params, HttpStatus.OK);
    }catch(Exception ae){
        params.put("error", "Failed to make payment");
        return new ResponseEntity<Map<String, Object>>(params, HttpStatus.OK);
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题