我正在尝试使用JpaRepository返回名称字段中包含特定字符串的任何记录。 我用http://localhost:8080/teacher?name=Poppy
给控制器打电话这是我的程序:
if 'PixelData' in dataset:
rows = int(dataset.Rows)
cols = int(dataset.Columns)
y=rows
x=cols
p=np.array(data)
fig = Figure(figsize=(6,6))
a = fig.add_subplot(111)
a.plot(p, range(2+y))
教师实体:
Sub fillLeads()
'
' fillLeads Macro
Last = Cells(Rows.Count, "B").End(xlUp).Row
cellValue = Range("B2").Value
openingParen = InStr(cellValue, "(")
closingParen = InStr(cellValue, ")")
enclosedValue = Mid(cellValue, openingParen + 1, closingParen - openingParen - 1)
For i = Last To 2 Step -1
Cells(i, "C").Value = enclosedValue
Next i
End Sub
教师资料库:
@RestController
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
private TeacherRepository teacherRepository;
@GetMapping
public List<Teacher> findAll(@RequestParam(name = "name") String strName) {
Teacher teacherExample = new Teacher();
teacherExample.setName(strName); //strName = "Poppy"
Example<Teacher> example = Example.of(teacherExample);
List<Teacher> teachers = teacherRepository.findAll(example);
return teachers; //the result are : [], I expected Ms. Poppy
}
}
Data.Sql
@Entity
public class Teacher {
@Id
private String id;
private String name;
Getter & Setter here..
}
我的其他控制器给我正确的结果。
@Repository
interface TeacherRepository extends JpaRepository<Teacher, String> {
}
谢谢
吉谷