Spring:实际请求参数未满足参数条件“loanTitle”

问题描述 投票:0回答:1

Java Spring MVC。没有参数我无法打开网址。我在互联网上找到了建议(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).
java spring
1个回答
0
投票

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

    @GetMapping(value= "objectloan")
    public String index(Model theModel, HttpSession session, @RequestParam(value = "loanTitle", required = false, defaultValue = "") Optional<String> loanTitle)
    {
....
    }
© www.soinside.com 2019 - 2024. All rights reserved.