Spring boot 请求方法';邮政';Springboot MVC中不支持
下面是我的GET和POST方法。。 在运行应用程序时,出现以下错误:不支持请求方法“POST” 获取方法:Spring boot 请求方法';邮政';Springboot MVC中不支持,spring-boot,post,controller,thymeleaf,Spring Boot,Post,Controller,Thymeleaf,下面是我的GET和POST方法。。 在运行应用程序时,出现以下错误:不支持请求方法“POST” 获取方法: @RequestMapping(value = "userProfiles/{userId}/setup/Tool", method = RequestMethod.GET) public String ToolSetup(Model model, @PathVariable int userId, @RequestParam(value = "update", defaultValue
@RequestMapping(value = "userProfiles/{userId}/setup/Tool", method = RequestMethod.GET)
public String ToolSetup(Model model, @PathVariable int userId, @RequestParam(value = "update", defaultValue = "false") boolean update) {
model.addAttribute("formInput", new Resource());
model.addAttribute("userId", userId);
if (update) {
model.addAttribute("update", "update");
} else model.addAttribute("update", "");
return "Tool";
}
以下是我的发帖方法:
@RequestMapping(value = "/userProfiles/{userId}/setup/Tool", method = RequestMethod.POST)
@ResponseBody
public void makeVideo(@PathVariable Long userId, @ModelAttribute("formInput") Resource formInput,
Authentication authentication,
ModelMap modelMap,
@RequestParam("uploadingFiles") MultipartFile[] uploadingFiles,
@RequestParam("track_value") int trackNumber,
HttpServletResponse response) throws IOException, URISyntaxException, InterruptedException, FrameGrabber.Exception,FrameRecorder.Exception {
UserProfile userProfile = userProfileRepository.findOne(userId);
ArrayList<String> photos = new ArrayList<>();
String audioPath= audioPath1;
for(MultipartFile file : uploadingFiles){
photos.add(file.getName());
}
formInput.setUploadingFiles(photos);
modelMap.put("formInput", formInput);
//some processing with images and the audio
response.sendRedirect("/userProfiles/" + userId + "/Tool/Processing"); //redirect to notif. page, then redirect to logged in home
}
@RequestMapping(value=“/userProfiles/{userId}/setup/Tool”,method=RequestMethod.POST)
@应答器
public void makeVideo(@PathVariable Long userId,@ModelAttribute(“formInput”)资源formInput,
身份验证,
ModelMap ModelMap,
@RequestParam(“uploadingFiles”)MultipartFile[]uploadingFiles,
@RequestParam(“轨迹值”)int trackNumber,
HttpServletResponse响应)引发IOException、URISyntaxException、InterruptedException、FrameGrabber.Exception、FrameRecorder.Exception{
UserProfile UserProfile=userProfileRepository.findOne(userId);
ArrayList photos=新建ArrayList();
字符串audioPath=audioPath1;
用于(多部分文件:上载文件){
photos.add(file.getName());
}
formInput.setUploadingFiles(照片);
modelMap.put(“formInput”,formInput);
//对图像和音频进行一些处理
response.sendRedirect(“/userProfiles/”+userId+“/Tool/Processing”);//重定向到notif.page,然后重定向到登录主页
}
HTML:
我知道曾经有其他帖子与此相关,我已经尝试了他们推荐的所有解决方案,但似乎没有任何效果。。
感谢您的帮助 在浏览器中按F12键并捕获准确的url。很可能您正在请求另一个端点。我不确定我是否理解。您的浏览器是什么?看这个:您需要检测web向api rest发送的真正http请求是什么。这可以使用浏览器网络选项卡中的web控制台来完成。我认为您的web请求错误的http端点。
<form th:action="@{${#httpServletRequest.requestURI + '?update=true'}}" th:object="${formInput}" method="POST" enctype="multipart/form-data">