/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.yourcompany.struts.form.UserForm;
import y2ssh.zhangxianya.xmal3.biz.UserBiz;
import y2ssh.zhangxianya.xmal3.biz.impl.UserBizImpl;
import y2ssh.zhangxianya.xmal3.entity.User;
/**
* MyEclipse Struts
* Creation date: 07-12-2011
*
* XDoclet definition:
* @struts.action parameter="operate" validate="true"
*/
public class UserAction extends DispatchAction {
private UserBiz userBiz=new UserBizImpl();
/*
* Generated Methods
*/
public UserBiz getUserBiz() {
return userBiz;
}
public void setUserBiz(UserBiz userBiz) {
this.userBiz = userBiz;
}
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
String agree=request.getParameter("agree");
if("true".equals(agree))
{
return mapping.findForward("user");
}else
{
return mapping.findForward("agreement");
}
}
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException {
// TODO Auto-generated method stub
UserForm myForm=(UserForm)form;
User item=myForm.getItem();
if(userBiz.isExists(item.getUserName()))
{
request.setAttribute("msg","用户名已存在");
return mapping.findForward("user");
}else
{
userBiz.add(item);
request.setAttribute("msg", "添加用户成功!");
request.setAttribute("backurl", "index.jsp");
request.setAttribute("backname", "首页登录");
return mapping.findForward("success");
}
}
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException, ServletException {
// TODO Auto-generated method stub
request.getSession().removeAttribute("user");
request.setCharacterEncoding("gbk");
String suserName=request.getParameter("userName");
String userName=new String(suserName.getBytes("ISO8859_1"),"gbk");
String userPwd=request.getParameter("userPwd");
User user=userBiz.login(userName,userPwd);
System.out.println(user.getUserStatus());
System.out.println(UserBiz.user_status_forbid);
if(null!=user && user.getUserStatus()!=UserBiz.user_status_forbid)//登录成功
{
request.getSession().setAttribute("user", user);
if(user.getUserStatus()==UserBiz.user_status_admin)
{
return mapping.findForward("admin");
}else if(user.getUserStatus()==UserBiz.user_status_normal)
{
return mapping.findForward("index");
}
}
else
{
request.setAttribute("msg", "用户名或密码错误,登录失败。");
return mapping.findForward("index");
}
return null;
}
public ActionForward doLogout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
// TODO Auto-generated method stub
request.getSession().removeAttribute("user");
response.sendRedirect("index.jsp");
return null;
}
}
e拍在线拍卖系统,是一个在线交易平台
4星 · 超过85%的资源 需积分: 34 19 浏览量
2011-07-24
03:03:46
上传
评论
收藏 858KB RAR 举报
zhangxianya1
- 粉丝: 45
- 资源: 8
最新资源
- Fortran语言语法快速入门.pdf
- 明日方舟 年 鼠标指针.rar
- 全国银行经济监管可视化系统
- e商小二-供应链管理物流交仓创业商业计划书.rar
- Edge浏览器下载文件提示 “无法安全下载” 的解决方法
- 基于springboot+layui的医院日常耗材管理系统.zip
- Emkex亿迈克思新型互联网磁材供应链商业计划书.rar
- 计算机毕业设计-ASP.NET某店POS积分管理系统-销售情况,会员卡再发行数据生成(源代码+)-毕设源码实例.zip
- 计算机毕业设计-asp.net某店POS积分管理系统-清除履历表、日志表、月购买额(源代码+)-毕设源码实例.zip
- 计算机毕业设计-ASP.NET某店POS积分管理系统-积分实绩更新及销售状况统计(源代码+)-毕设源码实例.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈