📄 user1action.java
字号:
package com.easyjweb.action;
import com.easyjf.web.Globals;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
import com.easyjweb.business.User;
import com.easyjweb.business.UserManage;
/**
* 使用命令模式抽象Action建立起来的action
* @author
*
*/
public class user1Action extends AbstractCmdAction {
// 没有任何参数则显示登录框
public Page doInit(WebForm form, Module module) {
return doShowLogin(form, module);
}
// 显示登录框
public Page doShowLogin(WebForm form, Module module) {
return new Page("login", "/userLogin.html", Globals.PAGE_TEMPLATE_TYPE);
}
// 执行登录验证
public Page doLogin(WebForm form, Module module) {
String userName = (String) form.get("userName");
String password = (String) form.get("password");
User user = UserManage.simpleLogin(userName, password);
if (user != null)// 登录成功
{
form.addResult("user", user);
return new Page("success", "/userLoginResult.html",
Globals.PAGE_TEMPLATE_TYPE);
} else// 用户名或者密码错误
{
form.addResult("msg", "登录失败,用户名或者密码不正确!");
return new Page("login", "/userLogin.html",
Globals.PAGE_TEMPLATE_TYPE);
}
}
// 显示用户注册模板页面
public Page doReg(WebForm form, Module module) {
return new Page("reg", "/userReg.html", Globals.PAGE_TEMPLATE_TYPE);
}
// 保存用户注册信息
public Page doSave(WebForm form, Module module) {
User user = (User) form.toPo(User.class);
if (user.save()) {
form.addResult("msg", "用户注册成功!");
return new Page("login", "/userLogin.html",
Globals.PAGE_TEMPLATE_TYPE);
} else {
form.addResult("msg", "用户注册失败,用户名、密码及Email不能为空!");
return new Page("reg", "/userReg.html", Globals.PAGE_TEMPLATE_TYPE);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -