// 遍历输出每个学生信息 for(Student student : students){ System.out.printf("%d\t%s\n", student.getId(), student.getName()); }
for(Map<String, Object> info : infos){ System.out.printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n", (Long)info.get("id"), (Long)info.get("student_id"), info.get("student_name"), info.get("student_number"), info.get("gender"), dateFormat.format(info.get("birth_date")), // 格式化日期 info.get("contact"), info.get("address") ); }
修改SQL查询实现区分大小写的登录验证
要使MySQL查询区分大小写,有几种方法可以实现。以下是针对你提供的MyBatis mapper接口方法的修改方案:
方案1:使用BINARY关键字(推荐)
java
复制
// 用户登录(区分大小写) @Select("SELECT * FROM user WHERE BINARY username = #{username} AND BINARY password = #{password}") User login(@Param("username") String username, @Param("password") String password);
*BINARY
关键字会使MySQL进行二进制比较,从而区分大小写。
*不区分大小写时,使用utf8mb4_bin修改字段的排序规则,这个utf8mb4_bin设置后会区分大小写
/** * 启动系统 */ public static void start() throws Exception { System.out.println("=== 学生学籍管理系统 ==="); if(StaticData.loginAppByRole ==0){ while (true) { printMenuStudentbasic(); int choice = readIntInput("请选择操作:"); handleChoice(choice); } } else if(StaticData.loginAppByRole ==2){ while (true) { printMenuStudentbasic002(); int choice = readIntInput("请选择操作:"); handleChoice002(choice); } } }
if语句中的内容要加while