📄 appendmsgaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mokoda.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mokoda.entity.Client;
import mokoda.entity.Message;
import mokoda.entity.MessageDAO;
import mokoda.entity.Msg2client;
import mokoda.entity.Msg2clientDAO;
import mokoda.entity.Msg2clientId;
import mokoda.form.AppendmsgForm;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts
* Creation date: 12-20-2006
*
* XDoclet definition:
* @struts.action path="/append" name="appendForm" input="/msg/appendmsg.jsp" scope="request" validate="true"
* @struts.action-forward name="success" path="/success.jsp"
*/
public class AppendmsgAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if ("get".equals(request.getMethod().toLowerCase())) {
Client client = (Client) request.getSession().getAttribute("client");
if (client != null) {
request.setAttribute("topicid", request.getParameter("topicid"));
request.setAttribute("clientid", client.getId());
return new ActionForward("/msg/appendmsg.jsp");
} else {
request.setAttribute("inputPath", "/msg/appendmsg.jsp");
ActionErrors errors = new ActionErrors();
errors.add("errors", new ActionError("errors.need.login"));
saveErrors(request, errors);
return mapping.findForward("login");
}
}
AppendmsgForm msgform = (AppendmsgForm) form;
Message msg = new Message();
MessageDAO dao = new MessageDAO();
msg.setContent(msgform.getContent());
msg.setIstpc("false");
msg.setTitle(msgform.getTitle());
// Integer i = msgform.getTpcid();
msg.setTpcid(msgform.getTpcid());
dao.save(msg);
Msg2client mc = new Msg2client();
Msg2clientDAO mcdao = new Msg2clientDAO();
Msg2clientId mcid = new Msg2clientId();
mcid.setClientid(msgform.getClientid());
mcid.setMsgid(msg.getId());
mc.setId(mcid);
mcdao.save(mc);
mcdao.getSession().flush();
//request.setAttribute("topic", new MessageDAO().findById(msgform.getTpcid()));
//request.setAttribute("messages", MessageDAO.getAllMessages(msgform.getTpcid()));
return new ActionForward("/display.do?type=topic&tpcid=" + msgform.getTpcid());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -