📄 sendmailaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import vo.Person;
import com.yourcompany.struts.form.SendmailForm;
import dao.PersonDAO;
/**
* MyEclipse Struts Creation date: 09-26-2007
*
* XDoclet definition:
*
* @struts.action path="/sendmail" name="sendmailForm" input="/sendmail.jsp"
* scope="request" validate="true"
*/
public class SendmailAction 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) {
SendmailForm sendmailForm = (SendmailForm) form;// TODO Auto-generated
// method stub
boolean flag = true;
Person p = new Person();
p.setId(sendmailForm.getId());
p.setQuestion(sendmailForm.getQuestion());
p.setAnswer(sendmailForm.getAnswer());
ApplicationContext context = null;
context = new ClassPathXmlApplicationContext("applicationContext.xml");
PersonDAO q2 = (PersonDAO) context.getBean("per");
HttpSession session = request.getSession();
try {
flag = q2.isSucess(p);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (flag) {
session.setAttribute("person", p);
return mapping.findForward("sucess");
} else {
request.setAttribute("flag", new Boolean(flag));
return mapping.findForward("failure");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -