⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendaction.java

📁 A network chatroom,a a project of database ,is highlighted by my teacher,which using the newest tech
💻 JAVA
字号:
package org.yeeku.action;

import com.opensymphony.xwork2.ActionContext;
import java.util.*;
import org.yeeku.action.base.BaseAction;

import java.sql.*;
import java.util.Vector;
import org.apache.struts2.ServletActionContext;
import org.yeeku.service.ChatMessage;
import javax.servlet.ServletContext;
public class SendAction extends BaseAction
  {
	private String toname;
	private String content;
        
        @Override
	public String execute() throws Exception
	{
           Map session = ActionContext.getContext().getSession();
           String UserName=(String)session.get("username");
           ServletContext M_application=ServletActionContext.getServletContext();
           Calendar ca = Calendar.getInstance();
	   int nm=ca.get(Calendar.MINUTE);//当前分钟
           if(M_application.getAttribute(toname)!=null)
           {
	   int lm=Integer.parseInt(M_application.getAttribute(toname).toString());/*最后一次登陆的分钟*/
	   int judge=nm-lm;
           if(!(judge>2||(judge<0&&judge>-58))){
           String msg=UserName+"对"+toname+"说:"+content;  
                ChatMessage addmessage= new ChatMessage();
                addmessage.addToChatmsg(msg,M_application);
              }
            }
          java.util.Date date=new java.util.Date();
          String datetime=new Timestamp(date.getTime()).toString();
          String title=" ";       
          boolean messagesend=mgr.addMessage(UserName,toname,content,title,datetime);
          if(messagesend)
           {
          return SUCCESS;
           }
          else
          {
           addActionError("消息发送出错");
          }
        return "failure";
        }
       public void setContent(String content)
	{
		this.content = content;
	}
	public String getContent()
	{
		 return this.content;
	}
	public void setToname(String toname)
	{
		this.toname = toname;
	}
	public String getToname()
	{
		 return this.toname;
	}
        
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -