日期:2014-05-18 浏览次数:20693 次
<!-- 对应的java文件定义:public UserInf selectPublicName(String userName); -->
<select id="obtainedPublicName" resultType="zxw.model.UserInf" parameterType="java.lang.String">
select * from userInf
where user_name = #(userName,jdbcType=VARCHER)
</select>
//对应的包package zxw.dao
public interface UserInfMapper {
/**
* 根据名字查询数据
*/
UserInf obtainedPublicName(String userName);
}
//对应的包package zxw.service;
public interface UserInfServiceI {
/**
* 根据用户姓名查找用户是否存在
* @param name:用户姓名
* @return:用户信息
*/
public UserInf findByName(String userName);
}
//对应的包package zxw.service.impl;
@Service(value="userInfService")
public class UserInfServiceImpl implements UserInfServiceI {
@Autowired
private UserInfMapper userInfMapper;//spring autowired注入了
public UserInf findByName(String userName) {
return userInfMapper.obtainedPublicName(userName);
}
}