?? useraction.java
字號(hào):
package com.easyjweb.action;
import com.easyjf.web.Globals;
import com.easyjf.web.IWebAction;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjweb.business.User;
import com.easyjweb.business.UserManage;
/**
* 直接實(shí)現(xiàn)IWebAction接口實(shí)現(xiàn)的EasyJWeb Action,當(dāng)一個(gè)action要處理很多命令的時(shí)候,將會(huì)顯得比較復(fù)雜。這種情況我們推薦使用命令模式的抽象類AbstractCmdAction來(lái)實(shí)現(xiàn)
* @author Administrator
*
*/
public class userAction implements IWebAction {
public Page execute(WebForm form, Module module) throws Exception {
String command = (String) form.get("easyJWebCommand");
if ("reg".equals(command)) {
return new Page("reg", "/userReg.html", Globals.PAGE_TEMPLATE_TYPE);
} else if ("save".equals(command)) {
User user = (User) form.toPo(User.class);
if (user.save()) {
form.addResult("msg", "用戶注冊(cè)成功!");
return new Page("login", "/userLogin.html",
Globals.PAGE_TEMPLATE_TYPE);
} else {
form.addResult("msg", "用戶注冊(cè)失敗,用戶名、密碼及Email不能為空!");
return new Page("reg", "/userReg.html",
Globals.PAGE_TEMPLATE_TYPE);
}
} else if ("login".equals(command))// 提交登錄信息
{
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// 用戶名或者密碼錯(cuò)誤
{
form.addResult("msg", "登錄失敗,用戶名或者密碼不正確!");
return new Page("login", "/userLogin.html",
Globals.PAGE_TEMPLATE_TYPE);
}
} else {
// 進(jìn)入登錄
return new Page("login", "/userLogin.html",
Globals.PAGE_TEMPLATE_TYPE);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -