当前位置: 代码迷 >> Java Web开发 >> 密码 帐号的修改,该怎么解决
  详细解决方案

密码 帐号的修改,该怎么解决

热度:837   发布时间:2016-04-17 17:20:53.0
密码 帐号的修改
<table width="80%" border="1" cellspacing="0" cellpadding="2" align="center">
<form action="yangzheng.jsp">

<tr bgcolor="#ffffff">
<td><center><font color="black">修改用户密码</font></center></td>
</tr>
<form name="theform" action="" method=post onsubmit="returncheck_input()">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;<font size="2"> 请输入原密码<input type="password"
name="old_password" size="100"></font></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;<font size="2"> 请输入新密码<input type="password"
name="new_password_1" size="100"></font></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="2">请确认新密码<input type="password"
name="new_password_2" size="100"></font></td>
</tr>
<tr>
<td>
<center>
<input id="submit" type="submit" name="confirm" onclick="rec()" value=" 确认">&nbsp;&nbsp;&nbsp;&nbsp;
<input id="reset" type="reset" name="reinput" value="重填">
</form>
</center>
</td>
</tr>
</table>

我想不用数据库实现密码和账号的修改 yangzheng.jsp该咋写呢? 有啥好方法呢》? 望 高手指点!!

------解决方案--------------------
修改的账号密码肯定是要存到数据库的,不对数据库进行操作,相当于没改密码,除非你愿意把账号密码写到文件中,没人会这么做吧,操作数据库的效率要比流高得多,而且安全
------解决方案--------------------
Java code
File f = new File("c:/info.txt");FileOutputStream out = new FileOutputStream(f);out.write("userpasword".getBytes());out.flush();out.close();
------解决方案--------------------
更新就是更新文件了呗,以后和数据库也就没啥关系了,要验证用户名密码的话就读这个文件,读写文件的指定行效率太低了
------解决方案--------------------
探讨
Java code


File f = new File("c:/info.txt");
FileOutputStream out = new FileOutputStream(f);
out.write("userpasword".getBytes());
out.flush();
out.close();

------解决方案--------------------
探讨
引用:
更新就是更新文件了呗,以后和数据库也就没啥关系了,要验证用户名密码的话就读这个文件,读写文件的指定行效率太低了


更新文件就是这个咋办呢?

------解决方案--------------------
探讨
我再问一下 除了使用数据库 有哪些方法实现密码和账号的修改呢?

------解决方案--------------------
积极茫茫的写了一下:
UserInfo类
Java code
package com.ycom;import java.io.Serializable;public class UserInfo implements Serializable {    private static final long serialVersionUID = 7545258646123665837L;        private String userName;        private String password;    public String getUserName() {        return userName;    }    public void setUserName(String userName) {        this.userName = userName;    }    public String getPassword() {        return password;    }    public void setPassword(String password) {        this.password = password;    }}
------解决方案--------------------
测试类:UserTest (在main方法中切换方法调用,先调用addTest添加用户,要先创建文件,这个自己弄,我就不多说了)
  相关解决方案