如何在控制器方法返回响应实体时使用弹簧重定向
2022-09-02 09:08:07
我想写这样的东西:
@RequestMapping(value = { "/member/uploadExternalImage",
"/member/uploadExternalImage" }, method = RequestMethod.GET)
public ResponseEntity<String> handleFileUpload(@RequestParam String url,@RequestParam String fileName, RedirectAttributes redirectAttributes) {
...
return new ResponseEntity("Cannot save file " + fileName, HttpStatus.INTERNAL_SERVER_ERROR);
...
return "redirect:/member/uploadImage";
}
预期行为 - 重定向至控制器:
@RequestMapping(value = { "/member/createCompany/uploadImage",
"/member/uploadImage" })
@ResponseBody
public ResponseEntity<String> handleFileUpload(@Validated MultipartFileWrapper file,
BindingResult result, Principal principal
但我不能写它,因为它是字符串,但应该是"redirect:/member/uploadImage"
ResponseEntity
如何解决我的问题?