?? loginaction.java
字號:
package org.yeeku.action;
import com.opensymphony.xwork2.ActionContext;
import java.util.*;
import org.yeeku.action.base.BaseAction;
import java.util.Vector
import org.apache.struts2.ServletActionContext;
import org.yeeku.service.ChatMessage;
public class LoginAction extends BaseAction
{
private String user;
private String pass;
private String vercode;
@Override
public String execute() throws Exception
{
Map session = ActionContext.getContext().getSession();
String ver2 = (String )session.get("rand");
if (vercode.equals(ver2))
{
int userId = mgr.loginValid(user , pass);
if (userId > 0)
{
session.put("userId" , userId);
session.setAttribute("username",user);
int m=ca.get(Calendar.MINUTE);
ServletContext m_application=ServletActionContext.getServletContext();
if(m_application.getAttribute(user)==null){
if(m_application.getAttribute("chatUser")==null){//初始化用戶列表
Vector chatUser=new Vector();
chatUser.addElement(user);
m_application.setAttribute("chatUser",chatUser);
}
else{
Vector tempVector=(Vector)m_application.getAttribute("chatUser");
tempVector.addElement(user);
m_application.setAttribute("chatUser",tempVector);
}
}
m_application.setAttribute(user,Integer.toString(m));
String msg="[系統消息]"+user+"上線了";
ChatMessage addmessage= new ChatMessage;
addmessage.addToChatmsg(msg,m_application);
return SUCCESS;
}
else
{
addActionError("用戶名/密碼不匹配");
}
}
else
{
addActionError("驗證碼不匹配,請重新輸入");
}
return "failure";
}
public void setUser(String user)
{
this.user = user;
}
public String getUser()
{
return this.user;
}
public void setPass(String pass)
{
this.pass = pass;
}
public String getPass()
{
return this.pass;
}
public void setVercode(String vercode)
{
this.vercode = vercode;
}
public String getVercode()
{
return this.vercode;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -