PwdChangeAction.java
资源名称:bangong.rar [点击查看]
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:3k
源码类别:
OA系统
开发平台:
Java
- package officeol.mc.actions;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionForm;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.Action;
- import officeol.mc.tools.*;
- public class PwdChangeAction extends Action {
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- try{
- request.setCharacterEncoding("GBK");
- Tool tl = new Tool();
- String un = StringFilter.filter(tl.isNull(request.getParameter(
- "un").trim()));
- String pwd = StringFilter.filter(tl.isNull(request.getParameter(
- "pwd").trim()));
- String pwd1 = StringFilter.filter(tl.isNull(request.getParameter(
- "pwd1").trim()));
- String pwd2 = StringFilter.filter(tl.isNull(request.getParameter(
- "pwd2").trim()));
- DBConn dbc = new DBConn();
- if(un!=null){
- if(pwd!=null){
- if(pwd1!=null&&pwd2!=null){
- String csql = "select * from [user] where username = '" +
- un + "' and password = '"+tl.hash(pwd)+"'";
- if(dbc.getArray(csql)!=null){
- if(pwd1.equals(pwd2)){
- String sql = "update [user] set password ='"+
- tl.hash(pwd2)+"' where username = '"+un+"'";
- dbc.executeUpdate(sql);
- request.setAttribute("msg","修改成功!请紧记新密码 "+pwd2);
- }else{
- request.setAttribute("msg","两次输入新密码必须相同!");
- }
- }else{
- request.setAttribute("msg","旧密码输入错误!");
- }
- }else{
- request.setAttribute("msg","两次输入新密码都不能为空!");
- }
- }else{
- request.setAttribute("msg","原密码不能为空!");
- }
- }else{
- request.setAttribute("msg","用户名不能为空!");
- }
- }catch(Exception ex){
- ex.printStackTrace();
- request.setAttribute("msg","出现异常,请重试!");
- }
- return mapping.findForward("succ");
- }
- }