springboot实现模糊查询功能

使用springboot来实现模糊查询功能,在这之前我已经配置好了相关的依赖和yml。实体类我定义成Question,服务层私有化了searchmapper对象。直接进入controller类,代码如下:

public List<Question> query(String question){
     
	Example example =new Example(Question.class);
	System.out.println(question);
	Criteria cc= new example.createCriteria();
	cc.andLike("question","%"+question+"%);
	List<Question> list = seaerchmapper.selectByExample(example);
	for(Question question2:list){
     
		System.out.println(question2.toString());
	}
	return list;
}

你可能感兴趣的:(SpringBoot)