📄 methoddispatchaction.java
字号:
package com.jdon.jivejdon.presentation.action.dispatch;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.jdon.controller.WebAppUtil;
import com.jdon.jivejdon.model.HotKeys;
import com.jdon.jivejdon.service.AccountService;
import com.jdon.jivejdon.service.ForumMessageService;
import com.jdon.jivejdon.service.OthersService;
import com.jdon.jivejdon.service.ShortMessageService;
public class MethodDispatchAction extends DispatchAction {
private final static Logger logger = Logger.getLogger(MethodDispatchAction.class);
public ActionForward deleteUserMessages(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.debug("enter userMessageListDelete");
String username = request.getParameter("username");
ForumMessageService forumMessageService = (ForumMessageService) WebAppUtil.getService("forumMessageService", request);
forumMessageService.deleteUserMessages(username);
return mapping.findForward("deleteUserMessages");
}
public ActionForward hotkeys(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
logger.debug("enter hotkeys");
HotKeys hotKeys = (HotKeys) request.getSession().getServletContext().getAttribute("HOTKEYS");
if (hotKeys == null) {
OthersService othersService = (OthersService) WebAppUtil.getService("othersService", request);
hotKeys = othersService.getHotKeys();
request.getSession().getServletContext().setAttribute("HOTKEYS", hotKeys);
}
return mapping.findForward("hotkeys");
}
public ActionForward tags(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
logger.debug("enter tags");
String q = request.getParameter("q");
OthersService othersService = (OthersService) WebAppUtil.getService("othersService", request);
Collection c = othersService.tags(q);
request.setAttribute("TAGS", c);
return mapping.findForward("tags");
}
public ActionForward savetags(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
logger.debug("enter savetags");
String[] tagTitle = request.getParameterValues("tagTitle");
String threadId = request.getParameter("threadId");
OthersService othersService = (OthersService) WebAppUtil.getService("othersService", request);
othersService.saveTag(new Long(threadId), tagTitle);
return mapping.findForward("savetags");
}
// shortmessage.xml
public ActionForward checkReceiveShortMessages(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.debug("enter checkReceiveShortMessages");
AccountService accountService = (AccountService) WebAppUtil.getService("accountService", request);
com.jdon.jivejdon.model.Account account = accountService.getloginAccount();
if (account == null) {// not logged
request.setAttribute("NEWMESSAGES", 0);
return mapping.findForward("checkmsg");
}
ShortMessageService service = (ShortMessageService) WebAppUtil.getService("shortMessageService", request);
int count = service.checkReceiveShortMessages();
request.setAttribute("NEWMESSAGES", count);
return mapping.findForward("checkmsg");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -