【问题标题】:Spring: Parameter conditions "loanTitle" not met for actual request parametersSpring:实际请求参数不满足参数条件“loanTitle”
【发布时间】:2018-06-04 10:55:01
【问题描述】:

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

【问题讨论】:

  • 尝试定义@GetMapping(value="objectloan")

标签: java spring


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-14
    • 2014-05-01
    • 2012-03-22
    相关资源
    最近更新 更多