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

时间:2018-06-04 10:55:02

标签: java spring

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).

1 个答案:

答案 0 :(得分:0)

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

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