首页 > 解决方案 > 请求方法 'PUT' 不支持] 重定向到另一个端点时

问题描述

  @PutMapping(value = {"/change-password"},
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,
            produces = {MediaType.APPLICATION_JSON_VALUE})
    public RedirectView changePassword(@RequestBody PasswordChangeDTO dto
    , HttpServletResponse response
    ) throws GIOException {
Boolean isChanged = service.changePassword(dto);

//i have tried all of those
// response.sendRedirect("login");
//        response.sendRedirect("/login");
//        return new RedirectView("login");
//        response.sendRedirect("login");
return null;
}

我已经尝试了所有这些代码行以使其重定向到登录,但它没有。这是登录

  @GetMapping("/login")
public ModelAndView login(
        @RequestParam(value = "msg", required = false) String message) {

    Authentication authentication = SecurityUtil.getAuthentication();

它可以来这里。

从前端,它是匿名的。

像这样;:

            $.ajax({
                type: "PUT",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                url: "/change-password",
                data: stringifiedDTO,

我正确地看到了值并且它更改了密码。但不能重定向。我能做些什么?

标签: springredirect

解决方案


推荐阅读