package com.javaweb.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.javaweb.struts.bean.dataBean;
import com.javaweb.struts.form.dataLoginform;
import com.javaweb.struts.form.dataRegform;
import com.javaweb.struts.form.dataUpform;
public class dataAction extends DispatchAction {
/**
* 登录
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward Login(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
dataLoginform dloginform = (dataLoginform)form;
String username=dloginform.getUsername();
String password = dloginform.getPassword();
dataBean db = new dataBean();
if(db.selectBean(username, password)){
request.setAttribute("username", username+",您好!!!");
return mapping.findForward("success");
}else{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.login.connect"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
}
}
/**
* 注册
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward registered(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
//form bean 验证
dataRegform dregform = (dataRegform)form;
String regname = dregform.getRegname();
String regpwd = dregform.getRegpwd();
String telphone = dregform.getTelphone();
//bean 与数据库交换
dataBean db = new dataBean();
if(db.insertBean(regname, regpwd, telphone)){
request.setAttribute("regname",regname);
request.setAttribute("cc", "恭喜您注册成功!!欢迎加入我们!!");
return mapping.findForward("regSucc");
}else{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.login.connect"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
}
}
/**
* 更新
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward update(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
dataUpform dupform = (dataUpform)form;
String newpwd = dupform.getNewpwd();
String oldpwd = dupform.getOldpwd();
dataBean db = new dataBean();
if(db.updateBean(newpwd, oldpwd)){
request.setAttribute("modify", "密码修改成功!!!");
return mapping.findForward("modifySucc");
}else{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.login.connect"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
}
}
//删除
public ActionForward delete(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
return null;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
出问题的工程
共36个文件
jsp:8个
class:6个
java:6个
需积分: 9 1 下载量 41 浏览量
2008-12-24
19:26:41
上传
评论
收藏 31KB RAR 举报
温馨提示
这个是问题的那个工程,所有源文件都在里面 !!谢谢您啦!!
资源推荐
资源详情
资源评论
收起资源包目录
strutstest.rar (36个子文件)
strutstest
.project 1KB
.mymetadata 303B
WebRoot
dataLogin.jsp 2KB
success.jsp 1KB
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 7KB
web.xml 2KB
struts-config.xml 3KB
struts-bean.tld 9KB
struts-nested.tld 70KB
struts-html.tld 72KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
classes
com
javaweb
struts
bean
dataBean.class 3KB
Constants.class 522B
action
dataAction.class 4KB
form
dataRegform.class 2KB
dataUpform.class 2KB
dataLoginform.class 2KB
yourcompany
struts
ApplicationResources.properties 1KB
index.jsp 1KB
META-INF
MANIFEST.MF 39B
modifySucc.jsp 1KB
Login.jsp 2KB
modify.jsp 1KB
regSucc.jsp 1KB
registered.jsp 2KB
.myeclipse
src
com
javaweb
struts
bean
Constants.java 310B
dataBean.java 2KB
action
dataAction.java 3KB
form
dataLoginform.java 1KB
dataRegform.java 1KB
dataUpform.java 1KB
yourcompany
struts
ApplicationResources.properties 1KB
.mystrutsdata 262B
.classpath 475B
共 36 条
- 1
资源评论
liuna129
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功