spring - 请求方法 '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,
我正确地看到了值并且它更改了密码。但不能重定向。我能做些什么?
解决方案
推荐阅读
- java - 错误java.lang.NoClassDefFoundError:解析失败:Lorg/geotools/factory/StrictHints;
- python - Python .exe 使用 __VERSION__ 更新文件文本
- javascript - 如何动态更改 javascript 代码
- c# - 在 IIS 中发布后无法访问页面/文件夹
- java - 无法通过页面查询从 URL 获取 html
- python - 请求的操作需要提升(以管理员身份运行)python 3 - windows 10
- java - 使用 Collection.remove() 时 Java ConcurrentModificationException 背后的原因
- html - 如何制作带有悬停弹出的颜色网格?
- c - C:我需要从一个文本文件中提取一些数据,它一直在给我报错分段错误
- c# - 使用 IDP 登录时 SessionId 发生变化