网站服务器哪个好百度关键词推广2元一天
通过前期准备后,项目已经能够成功运行:
1、在文件UserMapper.java中添加如下代码:
List<User> selectUSerByIdDynamic(User user);
2、在文件UserMapper.xml中添加如下代码:
<select id="selectUSerByIdDynamic" resultType="com.cz.pojo.User">select * from user where 1=1<if test="id>0"></if></select>
3、测试代码:
@Testpublic void selectUserByIdDynamic(){SqlSession sqlSession = GetSqlSession.getSqlSession();UserMapper mapper = sqlSession.getMapper(UserMapper.class);User user = new User();List<User> users = mapper.selectUSerByIdDynamic(user);System.out.println(users);sqlSession.close();}
运行截图:
查询成功!