gpt4 book ai didi

java - Spring:实际请求参数不满足参数条件 "loanTitle"

转载 作者:太空宇宙 更新时间:2023-11-04 10:24:43 25 4
gpt4 key购买 nike

Java Spring MVC。如果没有参数,我无法打开 url。我在互联网上找到了建议( Spring MVC Thymeleaf Error: Parameter conditions not met for actual request parametershttp://www.baeldung.com/spring-requestmapping ),但它们没有帮助我。

@Controller
@RequestMapping("/loans/")
public class LoanController {

@Autowired
LoanDAO loanDAO;

@GetMapping(value= "objectloan", params = {"loanTitle"})
public String index(Model theModel, HttpSession session, @RequestParam(value = "loanTitle", required = false, defaultValue = "") Optional<String> loanTitle)
{
....
}

网址有效

http://localhost:8080/college/loans/objectloan?loanTitle=test

网址有错误

http://localhost:8080/college/loans/objectloan

错误:

Type Status Report
Message Parameter conditions "loanTitle" not met for actual request parameters:
Description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

最佳答案

由于 loanTitle 可能不会出现在您的查询网址中,因此请尝试在 Controller 方法中删除 params = {"loanTitle"}

    @GetMapping(value= "objectloan")
public String index(Model theModel, HttpSession session, @RequestParam(value = "loanTitle", required = false, defaultValue = "") Optional<String> loanTitle)
{
....
}

关于java - Spring:实际请求参数不满足参数条件 "loanTitle",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50678952/

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