我怎样才能得到所有对象从CrudRepository春季
@RequestMapping(value="/test", method=RequestMethod.GET)
public ModelAndView recoverPass(@RequestParam("num") int num) {
ModelAndView mv = new ModelAndView("test");
mv.addObject("lists",appRepo.findAll(num));
return mv;
}
我的浏览器,但没有结果输入http://localhost:8080/test?num=40数据库。 (int)
谢谢,我想找到具有特定字段值的所有对象 –
@RayEn,那么你应该使用'match'查询 – sunkuet02
@RayEn如果你想这样做,那么你将需要使用Spring数据查询方法。假设你的字段被称为带有字符串值的foo,然后向你的appRepo接口添加一个名为findByFoo(String foo)的方法,并且Spring数据会神奇地使它适用于你。 – Plog