Passing a class (“Country.class”) as an argument in Java

后端 未结 7 1106
感情败类
感情败类 2020-12-12 06:29

I\'m trying to make a method that takes an argument of Country.class, User.class etc, and returns argument.count().

All the po

7条回答
  •  难免孤独
    2020-12-12 07:20

    In the line

    renderArgs.put("countryCount", countModel(Country.class));
    

    you call countModel with a Class, but you have to call it with an instance of Country like this:

    Country country = new Country();
    renderArgs.put("countryCount", countModel( country );
    

提交回复
热议问题