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

📄 answeraction.java

📁 我的智囊团,学习三种框架很好的源码包含分页.
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package org.lxh.myzngt.struts.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import org.lxh.myzngt.dao.IAnswerDAO;
import org.lxh.myzngt.dao.IUserDAO;
import org.lxh.myzngt.struts.form.AnswerForm;
import org.lxh.myzngt.vo.Answer;
import org.lxh.myzngt.vo.Question;

/**
 * MyEclipse Struts Creation date: 07-01-2007
 * 
 * XDoclet definition:
 * 
 * @struts.action path="/answer" name="answerForm" input="/form/answer.jsp"
 *                parameter="status" scope="request" validate="true"
 */
public class AnswerAction extends DispatchAction {
	private IAnswerDAO ianswerdao;

	private IUserDAO iuserdao;

	/*
	 * Generated Methods
	 */

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward insert(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AnswerForm answerForm = (AnswerForm) form;
		String ccode = (String) request.getSession().getAttribute("ccode");
		String checkcode = answerForm.getCheckcode();
		if (!(checkcode.equals(ccode))) {
			ActionMessages errors = new ActionMessages();
			errors.add("checkcode", new ActionMessage("checkcode.error"));
			super.saveErrors(request, errors);
			return mapping.getInputForward();
		}
		// 增加用户的个人积分
		Answer ans = new Answer();
		ans.setAnstime(new Date());
		ans.setQuesans(answerForm.getQuesans());
		ans.setUserid(answerForm.getUserid());
		ans.setGrade(org.lxh.myzngt.util.IntegralGrade.getInstance()
				.getGradeInfo(Integer.parseInt(answerForm.getGrade())));
		ans.setStatus(2);
		Question q = new Question() ;
		q.setQid(Integer.parseInt(answerForm.getQid())) ;
		ans.setQuestion(q) ;
		try {
			this.ianswerdao.insert(ans);
			this.iuserdao.addIntegral(answerForm.getUserid(), 5);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapping.findForward("insertdo");
	}

	public ActionForward aa(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AnswerForm answerForm = (AnswerForm) form;
		String ccode = (String) request.getSession().getAttribute("ccode");
		String checkcode = answerForm.getCheckcode();
		if (!(checkcode.equals(ccode))) {
			ActionMessages errors = new ActionMessages();
			errors.add("checkcode", new ActionMessage("checkcode.error"));
			super.saveErrors(request, errors);
			return mapping.getInputForward();
		}
		return null;
	}

	public IAnswerDAO getIanswerdao() {
		return ianswerdao;
	}

	public void setIanswerdao(IAnswerDAO ianswerdao) {
		this.ianswerdao = ianswerdao;
	}

	public IUserDAO getIuserdao() {
		return iuserdao;
	}

	public void setIuserdao(IUserDAO iuserdao) {
		this.iuserdao = iuserdao;
	}
}

⌨️ 快捷键说明

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