我怎樣才能得到所有對象從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