使用@PathVariable时候无法将参数映射到变量中

    @GetMapping("find/name/{firstName}")//URI中的变量名称必须要与controller中的方法实参明一致
    public String findPeopleByFirtName(@PathVariable String firstName){//这必须与URI中的名称一致

        List<People> peoples = peopleDAO.findByFirstName(firstName);
        peoples.forEach(p->System.out.println(p));
        return "查询成功";
    }

第一次时,URI中为firstname,方法名中使用了firstName结果报错

然后改为一致,URI中使用firstName,方法名中使用firstName问题解决。

猜你喜欢

转载自blog.csdn.net/titymt/article/details/80881453