gpt4 book ai didi

java - HTTP 状态 405 - 在 spring mvc 中执行 return 'GET' 时不支持请求方法 "redirect:*.*"

转载 作者:行者123 更新时间:2023-12-02 04:18:55 25 4
gpt4 key购买 nike

在 Spring MVC 中...记录更新后我必须重新加载页面。因此,在操作方法中,我返回 String,作为返回,我返回

 return "redirect:/recordList";

当页面出现异常时

 HTTP Status 405 - Request method 'GET' not supported

日志上没有异常。

我的 Controller 方法看起来像

    @RequestMapping(value= "/recordList", method = RequestMethod.POST)
public ModelAndView getAssetListForUser(@RequestParam("ldapId") String ldapId,
final HttpServletRequest request){

另外,因为我需要 Controller 方法中的 ldapId 值,所以我将其绑定(bind)在调用方法中,如下所示

     request.setAttribute("ldapId", assetAssetEmp.getAssetEmpId());

请帮忙。

最佳答案

看起来您的 /recordList Controller 方法仅支持 RequestMethod.POST。因此,您会收到 405 GET Method not allowed 错误,因为重定向将发出 GET 请求。

要解决这个问题,请尝试提供 Controller 操作的 GET 版本。 (assetlist方法)这样一旦发生更新,就可以通过GET方法返回用户的 Assets 列表。

关于java - HTTP 状态 405 - 在 spring mvc 中执行 return 'GET' 时不支持请求方法 "redirect:*.*",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986640/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com