Springboot MVC不支持请求方法“ POST”

时间:2018-08-03 20:22:43

标签: spring-boot post controller thymeleaf

下面是我的GET和POST方法。 运行应用程序时,出现以下错误:请求方法'POST'不支持。

GET方法:

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

下面是我的POST方法:

    @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

}  

HTML:

       <form th:action="@{${#httpServletRequest.requestURI + '?update=true'}}" th:object="${formInput}" method="POST" enctype="multipart/form-data">

我知道曾经有与此相关的其他帖子,我已经尝试了所有推荐的解决方案,但似乎无济于事。 任何帮助表示赞赏!

0 个答案:

没有答案