更新时间:2023-09-11 22:27:46
根据您的用户名遵循的规则,只需使用正则表达式来验证 userName:
Simply use a regular expression to validate the userName according to the rules your usernames follow:
if(userName.matches("[0-9a-zA-Z_]+")
session.setAttribute(Constant.USERNAME, userName);