我當(dāng)初用struts1和hibernate做了個(gè)簡(jiǎn)單的!主要的邏輯代碼在下面!數(shù)據(jù)庫(kù)里號(hào)碼對(duì)應(yīng)的城市在網(wǎng)上可以查的到
10年積累的網(wǎng)站制作、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)制作后付款的網(wǎng)站建設(shè)流程,更有綏陽免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
package dao;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Expression;
import entity.Shenfenzhen;
public class IdDao {
private static Configuration configuration = new Configuration().configure() ;
private static SessionFactory sessionFactory =configuration.buildSessionFactory();
private static Session session = null;
public Info query(String s){
Info info = null;
StringBuffer stringBuffer = new StringBuffer(s);
if(s.length()==18){
String end = stringBuffer.substring(17);
//System.out.println(end);
if(!end.matches("\\d||x")){
return null;
}
}
else if(s.length()==15){
stringBuffer.insert(6, "19");
stringBuffer.append("3");
}
int i = Integer.parseInt(stringBuffer.substring(0, 6));
//System.out.println(i);
session = sessionFactory.openSession();
Criteria criteria = session.createCriteria(Shenfenzhen.class);
criteria.add(Expression.eq("num", i));
ListShenfenzhen list = criteria.list();
String address = null;
try {
address = list.get(0).getAddress();
}catch (Exception e) {
return null;
}
i = Integer.parseInt(stringBuffer.substring(16,17));
String sex = null;
if(i%2==0){
sex = "女";
}else{
sex = "男";
}
//System.out.println(i);
stringBuffer = new StringBuffer(stringBuffer.substring(6, 14));
// stringBuffer.insert(4, "-");
// stringBuffer.insert(7, "-");
//System.out.println(stringBuffer);
String ss = stringBuffer.toString();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String brithday="";
int year=0;
int month =0;
int day =0;
try {
Date date = dateFormat.parse(ss);
//System.out.println(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH)+1;
day = calendar.get(Calendar.DAY_OF_MONTH);
brithday = (String)(year + "年" + month + "月" + day + "日");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
info = new Info(address, brithday, sex);
Calendar c = Calendar.getInstance();
int nowYear = c.get(Calendar.YEAR);
int nowMonth = c.get(Calendar.MONTH);
int nowDay = c.get(Calendar.DAY_OF_MONTH);
if(nowYearyear){
info = null;
}else if(nowYear ==year nowMonthmonth ){
info = null;
}else if(nowYear == year nowMonth==month nowDayday){
info = null;
}
closeSession(session);
return info;
}
// public static void main(String[] args){
// IdDao dao = new IdDao();
// dao.query("342522998711224513");
// System.out.println("x".matches("\\d||x"));
// }
private void closeSession(Session session){
if(session !=null){
session.close();
}
}
}
package?com.yanlun.starter.utils;
import?java.util.regex.Pattern;
/**
*?@author?作者:Yan,Email:yanlun0323@163.com
*?@version?創(chuàng)建時(shí)間:2017年5月26日?上午10:42:09
*/
public?class?Validation?{
public?static?final?Pattern?REX_DATE_YYYYMM_PATTERN?=?Pattern.compile("^[0-9]{6}$");
public?static?final?Pattern?REX_DATE_YYYYMMDD_PATTERN?=?Pattern.compile("^[0-9]{8}$");
//?身份證校驗(yàn)加權(quán)因子
public?static?final?Integer[]?ID_NUM_FACTOR?=?new?Integer[]?{?7,?9,?10,?5,?8,?4,?2,?1,?6,?3,?7,?9,?10,?5,?8,?4,?2,
1?};
//?身份證第18位校驗(yàn)碼
public?static?final?String[]?ID_NUM_PARITY_BIT?=?new?String[]?{?"1",?"0",?"X",?"9",?"8",?"7",?"6",?"5",?"4",?"3",
"2"?};
/*
?*?是否空字符串
?*?
?*?@param?c?文本或其它基本數(shù)字類型對(duì)象
?*/
public?static?boolean?isEmpty(Object?c)?{
return?c?==?null?||?c.toString().trim().equals("");
}
/**
?*?判斷是否為“”式的時(shí)期
?*?
?*?@param?dateStr
?*?@return
?*/
private?static?boolean?isDate6(String?dateStr)?{
if?(isEmpty(dateStr)?||?!REX_DATE_YYYYMM_PATTERN.matcher(dateStr).matches())?{
return?false;
}
return?isValidDateRange(date6Split(dateStr));
}
/**
?*?判斷是否為“YYYYMMDD”式的時(shí)期
?*?
?*?@param?dateStr
?*?@return
?*/
private?static?boolean?isDate8(String?dateStr)?{
if?(isEmpty(dateStr)?||?!REX_DATE_YYYYMMDD_PATTERN.matcher(dateStr).matches())?{
return?false;
}
return?isValidDateRange(date8Split(dateStr));
}
private?static?boolean?isLeapYear(Integer?year)?{
return?((year?%?4?==?0)??(year?%?100?!=?0))?||?(year?%?400?==?0);
}
private?static?boolean?isInvalidYear(Integer?year)?{
return?year??1700?||?year??2500;
}
private?static?boolean?isInvalidMonth(Integer?month)?{
return?month??1?||?month??12;
}
private?static?boolean?isInvalidDay(Integer?day,?Integer?month,?Integer?year)?{
Integer[]?iaMonthDays?=?new?Integer[]?{?31,?28,?31,?30,?31,?30,?31,?31,?30,?31,?30,?31?};
if?(isLeapYear(year))
iaMonthDays[1]?=?29;
return?day??1?||?day??iaMonthDays[month?-?1];
}
/**
?*?split?date?0-YY,1-MM,2-DD
?*?
?*?@param?dateStr
?*?@return
?*/
private?static?Integer[]?date6Split(String?dateStr)?{
final?Integer?YEAR_BASE?=?1900;
Integer?year?=?null,?month?=?null,?day?=?null;
year?=?YEAR_BASE?+?Integer.valueOf(dateStr.substring(0,?2));
month?=?Integer.valueOf(dateStr.substring(2,?4));
day?=?Integer.valueOf(dateStr.substring(4,?6));
return?new?Integer[]?{?year,?month,?day?};
}
/**
?*?split?date?0-YYYY,1-MM,2-DD
?*?
?*?@param?dateStr
?*?@return
?*/
private?static?Integer[]?date8Split(String?dateStr)?{
Integer?year?=?null,?month?=?null,?day?=?null;
year?=?Integer.valueOf(dateStr.substring(0,?4));
month?=?Integer.valueOf(dateStr.substring(4,?6));
if?(dateStr.length()?==?8)?{
day?=?Integer.valueOf(dateStr.substring(6,?8));
return?new?Integer[]?{?year,?month,?day?};
}?else?{
return?new?Integer[]?{?year,?month?};
}
}
private?static?boolean?isValidDateRange(Integer[]?dateSplitResult)?{
Integer?year?=?dateSplitResult[0],?month?=?dateSplitResult[1],?day?=?dateSplitResult[2];
if?(isInvalidYear(year))
return?false;
if?(isInvalidMonth(month))
return?false;
if?(isInvalidDay(day,?month,?year))
return?false;
return?true;
}
/**
?*?18位/15位身份證號(hào)碼校驗(yàn)
?*?
?*?@param?idNumber
?*?@return
?*/
public?static?boolean?isIdentityCardNum(String?idNumber)?{
if?(isEmpty(idNumber)?||?(idNumber.length()?!=?18??idNumber.length()?!=?15))?{
return?false;
}
//?initialize
if?(idNumber.length()?==?18)?{
//?check?date
String?date8?=?idNumber.substring(6,?14);
if?(isDate8(date8)?==?false)?{
return?false;
}
int?totalMulAiWi?=?0;
char?charAt;
//?check?and?set?value,?calculate?the?totalmulAiWi
for?(int?i?=?0;?i??17;?i++)?{
charAt?=?idNumber.charAt(i);
if?(charAt??'0'?||?charAt??'9')?{
return?false;
}
totalMulAiWi?+=?Integer.valueOf(String.valueOf(charAt))?*?ID_NUM_FACTOR[i];
}
//?calculate?the?check?digit
String?checkDigit?=?ID_NUM_PARITY_BIT[totalMulAiWi?%?11];
//?check?last?digit
if?(!checkDigit.equalsIgnoreCase(String.valueOf(idNumber.charAt(17))))?{
return?false;
}
}?else?{//?length?is?15
//?check?date
String?date6?=?idNumber.substring(6,?12);
if?(isDate6(date6)?==?false)?{
return?false;
}
}
return?true;
}
}
private static final String onlyNum = "^[0-9]*{1}“;
/**
* 驗(yàn)證身份證號(hào)碼
* @param id_number
* @return
*/
public static Boolean checkNID(String id_number){
Boolean isRight = false;
if(id_number.length() != 15 id_number.length() != 18){
return false;
}
String string = id_number.substring(0, id_number.length() - 1);
if(!string.matches(onlyNum)){
return false;
}
if(id_number.length() == 15){
return is15IDNumberRight(id_number);
} else if(id_number.length() == 18){
return is18IDNumberRight(id_number);
}
return isRight;
}
跑這兒作家庭作業(yè)了? 如果連用哪種頁(yè)面技術(shù)都不知道提的話,恐怕別人給你源代碼你也看不懂哦,想想別人給你個(gè)tapestry、Wicket之類的寫的代碼,拿給老師肯定挨批的喲(一看就露餡了)。
你的程序有一點(diǎn)小問題,m的值沒改變,我給你改了一下,你看看吧。
import java.util.*;
class User{
private String userName,password;
User(){
System.out.println("輸入用戶名:");
Scanner reader=new Scanner(System.in);
userName=reader.nextLine();
System.out.println("輸入密碼:");
Scanner reader1=new Scanner(System.in);
password=reader1.next();
}
void check(){
int m=0;
int n=0;
if(userName.equals("")==true || userName==null)
m=0;
else
m=userName.length();
if(password.equals("12345678")==true)
n=1;
if(m!=0 n==1){
System.out.println("用戶名有效");
}else{
System.out.println("用戶名無效");
}
}
}
public class Users {
public static void main(String[] args){
User user=new User();
user.check();
}
}
文章題目:java實(shí)名認(rèn)證源代碼,java實(shí)名認(rèn)證接口
當(dāng)前地址:http://m.rwnh.cn/article32/phjpsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、企業(yè)建站、品牌網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站收錄、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)