Development environment: Jdk1.7,eclipse
Framework: Springmvc,mybatis
Tools: Maven
Following code replication enables MD5 encryption create a Mave project, plus the web. Don't know how to search it. Registers the user's JSP page code as follows.
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%> <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
You need to build a userdto class yourself, and I use the Userdto property to pass the value.
also to introduce jquery MD5, search, I do not know how to upload this file to the above for you to download.
Http://pan.baidu.com/s/1bp9t8Vd to the network disk JSP landing page code,
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%> <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
then write the background code
Package Com.test.controller;
Import Javax.annotation.Resource;
Import Org.springframework.stereotype.Controller;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.servlet.ModelAndView;
Import Com.test.dao.UserDao;
Import Com.test.model.UserDto;
/** * * * @author halfway decent * */@Controller public class Userlogin {@Resource Userdao Userdao; * * Add User */@RequestMapping ("/insertuser") public Modelandview Insertuser (userdto userdto) {//Enter
Line encryption, the page is passed not plaintext, is a hash value, and then encrypt the hash String s=userdto.getuser_psw ();
String Smi=convertmd5 (s);
USERDTO.SETUSER_PSW (SMI);
Userdao.insertuser (userdto);
return new Modelandview ("newfile.jsp");
/* * Verify username/@RequestMapping ("/authuser") public Modelandview Authuser (userdto userdto) {
int i=0;
The hash password passed to the user login is encrypted first with String S=USERDTO.GETUSER_PSW ();
String Smi=convertmd5 (s); AddUSERDTO.SETUSER_PSW (SMI) is compared with the password stored in the database.
try {i=userdao.login (userdto);
catch (Exception e) {//TODO auto-generated catch block E.printstacktrace ();
} if (i==1) {System.out.println ("User logon succeeded");
}else{System.out.println ("User Login failed");
Return to New Modelandview ("newfile.jsp"); /** * Encryption decryption algorithm performs once encryption, two decryption/public static string ConvertMD5 (String inStr) {Char
[] A = Instr.tochararray ();
for (int i = 0; i < a.length i++) {A[i] = (char) (a[i] ^ ' t ');
string s = new String (a);
return s; }
}
This makes a simple MD5 encryption. Other default code is very simple, not all write out, read logic will do.
Attach the password saved in the database is this. The
is also a point of insufficient advice.