Java Spring MVC。没有参数我无法打开网址。我在互联网上找到了建议(Spring MVC Thymeleaf Error: Parameter conditions not met for actual request parameters,http://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
有错误的网址
错误:
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
可能不会出现在您的查询网址中,请尝试在控制器方法中删除params = {"loanTitle"}
@GetMapping(value= "objectloan")
public String index(Model theModel, HttpSession session, @RequestParam(value = "loanTitle", required = false, defaultValue = "") Optional<String> loanTitle)
{
....
}