【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“CustomerFindAllAction.java”一文,供大家参考学习!
package com.relationinfo.customertrace.struts.actions;
import org.apache.struts.*;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.*;
import java.math.*;
import com.relationinfo.customertrace.dao.*;
import com.relationinfo.customertrace.dto.*;
import com.relationinfo.customertrace.factory.*;
import com.relationinfo.customertrace.struts.forms.*;
public class CustomerFindAllAction extends Action
{
/**
* Method 'execute'
*
* @param mapping
* @param form
* @param request
* @param response
* @throws Exception
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
try {
// 解析参数
//创建Dao类
CustomerDao dao = CustomerDaoFactory.create();
// 执行
查询 Customer dto[] = dao.findAll();
// 存储结果
request.setAttribute( "result", dto );
return mapping.findForward( "success" );
}
catch (Exception e) {
ActionErrors _errors = new ActionErrors();
_errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage() ) );
saveErrors( request, _errors );
return mapping.findForward( "failure" );
}
}
}