毕业设计中需要用到记住账号密码的功能,网上搜到了一个解决方案,自己稍加改造就是下面的方法。
首先是登录的页面,当用户勾选记住密码,传递给controller(我用的SSM框架),后台设置cookie的值,然后下次登录的时候就不用再次输入账号和密码了。
login.jsp的代码:
<%@page import="org.apache.commons.lang.StringUtils"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@include file="public/nocache.jsp" %> <%@include file="public/header.jsp" %>body{ margin:0px; padding:0px; } .wrapper{ width:100%;height:100%;position:fixed; } .content{ width:100%; height:100%; position:relative; text-align:center; } .login{ width:1050px; height:450px; position:absolute; top:50%; left:50%; margin-top:-225px; margin-left:-525px; } <%@include file="public/headertop.jsp" %> <%-- 读取cookie --%> <% String name = ""; String password = ""; try{ cookie[] cookies = request.getcookies(); if(cookies!=null){ for(int i = 0;i 汽车维修管理系统
Vehicle Maintenance Management System


