package com.jack.user.action;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.struts2.interceptor.SessionAware;
import com.jack.user.model.IUserServices;
import com.jack.user.pojo.User;
import com.jack.user.pojo.UserInfor;
public class LoginAction implements SessionAware {
private User user;
private String userName;
private String password;
private String name;
private String email;
private String age;
private String sex;
private String address;
private String tip;
private Map session;
private IUserServices userServices;
public void setUserServices(IUserServices userServices) {
this.userServices = userServices;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return this.userName;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
/**
* 用户登录
*
* @return
* @throws Exception
*/
public String userLogin() throws Exception {
String result = null;
try {
boolean flag = userServices.checkUser(this.getUserName(), this
.getPassword());
if (flag) {
result = "success";
} else {
this.setTip("<font color='red'>对不起您的帐号或密码有误!</font>");
result = "noUser";
}
} catch (Exception e) {
this.setTip("<font color='red'>对不起,系统出现故障,请稍后再登录!</font>");
e.printStackTrace();
result = "noUser";
}
return result;
}
public String saveAccount() {
String result = null;
try {
session.put("userName", this.getUserName());
session.put("password", this.getPassword());
result = "success";
} catch (Exception e) {
e.printStackTrace();
result = "error";
}
return result;
}
public String userRegister() {
String result = "";
try {
user = new User();
String uname = (String) session.get("userName");
String pwd = (String) session.get("password");
user.setUserName(uname);
user.setPassword(pwd);
//级联关系部分
Set set = new HashSet();
System.out.println("得到的真实姓名:" + this.getName());
UserInfor userInfor = new UserInfor();
userInfor.setName(this.getName());
userInfor.setEmail(this.getEmail());
userInfor.setSex(this.getSex());
userInfor.setAddress(this.getAddress());
userInfor.setAge(Integer.parseInt(this.getAge()));
userInfor.setUser(user);
set.add(userInfor);
//设置添加对象
user.setUserInfors(set);
userServices.saveUser(user);
result = "success";
} catch (Exception e) {
this.setTip("系统出现故障!");
result = "error";
e.printStackTrace();
}
return result;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
public void setSession(Map session) {
this.session = session;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
UserSystem.rar (80个子文件)
UserSystem
.project 2KB
test
test
com
jack
user
dao
TestUserDAO.java 626B
model
TestUserServices.java 836B
.mymetadata 303B
WebRoot
login.jsp 1KB
WEB-INF
dwr.xml 340B
web.xml 1KB
lib
commons-logging.jar 59KB
cglib-nodep-2.1_3.jar 317KB
slf4j-log4j12-1.5.0.jar 9KB
jta.jar 9KB
hibernate3.jar 2.26MB
asm-2.2.3.jar 34KB
log4j-1.2.15.jar 383KB
ognl-2.6.11.jar 164KB
msbase.jar 280KB
xwork-2.0.5.jar 447KB
mssqlserver.jar 66KB
freemarker-2.3.8.jar 784KB
slf4j-api-1.5.0.jar 16KB
dom4j-1.6.1.jar 307KB
dwr.jar 478KB
struts2-core-2.0.11.2.jar 2.22MB
msutil.jar 58KB
antlr-2.7.6.jar 433KB
commons-collections.jar 558KB
spring.jar 2.81MB
aspectjweaver.jar 1.82MB
struts2-spring-plugin-2.0.11.2.jar 9KB
classes
test
com
jack
user
dao
TestUserDAO.class 1KB
model
TestUserServices.class 1KB
struts.properties 26B
com
jack
user
dao
IUserDAO.class 433B
impl
UserInforDAO.class 2KB
UserDAO.class 4KB
IUserInforDAO.class 385B
action
userOperation.xml 832B
LoginAction.class 5KB
model
IUserServices.class 362B
impl
ValidatorUser.class 2KB
UserServices.class 1KB
config
dao.xml 796B
servicesContext.xml 2KB
applicationContext.xml 359B
hibernate.cfg.xml 1KB
pojo
UserInfor.hbm.xml 1KB
User.class 1KB
UserInfor.class 2KB
User.hbm.xml 1KB
struts.xml 279B
index.jsp 33B
META-INF
MANIFEST.MF 39B
register.jsp 2KB
common
register.js 1KB
userInfor.jsp 2KB
welcome.jsp 732B
.myeclipse
src
struts.properties 26B
com
jack
user
dao
IUserInforDAO.java 1KB
impl
UserInforDAO.java 1KB
UserDAO.java 2KB
IUserDAO.java 2KB
action
LoginAction.java 4KB
userOperation.xml 832B
model
IUserServices.java 900B
impl
ValidatorUser.java 1KB
UserServices.java 690B
config
dao.xml 796B
servicesContext.xml 2KB
applicationContext.xml 359B
hibernate.cfg.xml 1023B
pojo
UserInfor.java 1KB
UserInfor.hbm.xml 1KB
User.java 1KB
User.hbm.xml 1KB
log4j.xml 1KB
log4j.dtd 5KB
struts.xml 279B
.springBeans 459B
.classpath 3KB
.myhibernatedata 574B
共 80 条
- 1
资源评论
jaflee
- 粉丝: 9
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功