gpt4 book ai didi

java - Spring 参数不起作用

转载 作者:行者123 更新时间:2023-11-29 03:36:12 25 4
gpt4 key购买 nike

使用 spring params 的注释不起作用。

@RequestMapping(value = "/login", method = RequestMethod.PUT)
public @ResponseBody ResponseMsg login(@RequestParam String userName, @RequestParam String password )
{
ResponseMsg responseMsg = CommonUtils.checkParam(userName, password);

if(responseMsg.getStatus().equalsIgnoreCase("True"))
{
responseMsg = userService.login(userName, password);
}
return responseMsg;
}

我正在使用此函数获取 put 中的值,但它显示 400 Bad Request。有帮助吗?

最佳答案

正确答案是这个...感谢 OQJF

@RequestMapping(value = "/login", method = RequestMethod.GET)
public @ResponseBody ResponseMsg login(@RequestHeader(value="username", required=false) String userName,
@RequestHeader(value="password", required=false) String password ) {

ResponseMsg responseMsg = CommonUtils.checkParam(userName, password);
if(responseMsg.getStatus().equalsIgnoreCase("True"))
responseMsg = userService.login(userName, password);
return responseMsg;
}

关于java - Spring 参数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15405323/

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