policyaction.java
来自「培训考试系统代码」· Java 代码 · 共 481 行 · 第 1/2 页
JAVA
481 行
req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
return (mapping.findForward("error"));
}
catch(java.sql.SQLException sqle)
{//捕获调用aplcoms异常,定向到出错页面
// 输出异常信息
sqle.printStackTrace();
req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
return (mapping.findForward("error"));
}
catch(Exception e)
{//捕获未知异常,定向到出错页面
//输出异常信息
e.printStackTrace();
req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
return (mapping.findForward("error"));
}
finally
{//关闭连接实例
if(aplcoms != null)
{
aplcoms.close();
}
}
}
/**
* 删除策略操作
*/
private ActionForward deletePolicy(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
//从PolicyFrom中获取策略ID号
String[] policyIds = ((PolicyForm)form).getPolicyIds();
//以"#"号组合所要删除的策略,之间以"#"号分割
String policyIdSet = Tools.getStringSet(policyIds);
//定义连接的实例
SysDbConn aplcoms = null;
try
{
//得到一个连接的实例
aplcoms = SysConnPool.getInstance().getAplComs();
//调用存储过程 P_Agt_PolicyDel完成策略的删除
aplcoms.preparedSP();
aplcoms.setString(1 ,policyIdSet);
SysDataSet ds = aplcoms.csCommonSP("P_Agt_PolicyDel");
SysRecord rc = ds.getParamSet() ;
if(rc!=null && rc.getInt(0) == OperatorFlagCode.OPERATOR_SUCCESS)
{//删除策略成功
//调用queryPolicy函数进行重新查询后返回到列表页面
return queryPolicy(mapping,form,req,res);
}
else
{
//定向到错误页面,错误号为POLICY_DELETE_ERROR;
req.setAttribute("errorId",ErrorCode.POLICY_DELETE_ERROR);
return (mapping.findForward("error"));
}
}
catch (SysDbException aple)
{//捕获CommonService系统异常,定向到出错页面
//输出异常信息
aple.printStackTrace();
req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
return (mapping.findForward("error"));
}
catch(java.sql.SQLException sqle)
{//捕获调用aplcoms异常,定向到出错页面
// 输出异常信息
sqle.printStackTrace();
req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
return (mapping.findForward("error"));
}
catch(Exception e)
{//捕获未知异常,定向到出错页面
//输出异常信息
e.printStackTrace();
req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
return (mapping.findForward("error"));
}
finally
{//关闭连接实例
if(aplcoms != null)
{
aplcoms.close();
}
}
}
/**
* 查询策略操作
*/
private ActionForward queryPolicy(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
//从PolicyForm中获取查询条件;
String titleTerm = ((PolicyForm)form).getTitleTerm();
//定义连接的实例
SysDbConn aplcoms = null;
try
{
//得到一个连接的实例
aplcoms = SysConnPool.getInstance().getAplComs();
//根据查询条件,从数据库中获取策略记录
aplcoms.preparedQuery("");
SysResultSet rs = null;
if(titleTerm != null)
{//按照名称进行查询
aplcoms.setString(1 ,titleTerm);
rs = aplcoms.csCommonQuery("SQL_Agt_PolicyQueryByTitle" ,"1" ,"-1").getResultSet();
}
else
{//查询所有
rs = aplcoms.csCommonQuery("SQL_Agt_PolicyQueryAll" ,"1" ,"-1").getResultSet();
}
//把结果集存放到session中
req.getSession().setAttribute("POLICY-QUERY-RESULTSET",rs);
//定向到列表显示页面
return (mapping.findForward("policylist"));
}
catch (SysDbException aple)
{//捕获CommonService系统异常,定向到出错页面
//输出异常信息
aple.printStackTrace();
req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
return (mapping.findForward("error"));
}
catch(java.sql.SQLException sqle)
{//捕获调用aplcoms异常,定向到出错页面
// 输出异常信息
sqle.printStackTrace();
req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
return (mapping.findForward("error"));
}
catch(Exception e)
{//捕获未知异常,定向到出错页面
//输出异常信息
e.printStackTrace();
req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
return (mapping.findForward("error"));
}
finally
{//关闭连接实例
if(aplcoms != null)
{
aplcoms.close();
}
}
}
/**
* 查询策略详细信息操作
*/
private ActionForward queryPolicyDetail(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
//从PolicyFrom中获取策略的ID号与名称
String policyId = ((PolicyForm)form).getPolicyId();
if(policyId == null)
{//从列表中传过来的参数
policyId = (((PolicyForm)form).getPolicyIds())[0];
}
//从PolicyFrom中获取操作类型;
String opeType = ((PolicyForm)form).getOpeType();//从form中获取
//定义连接的实例
SysDbConn aplcoms = null;
try
{
//得到一个连接的实例
aplcoms = SysConnPool.getInstance().getAplComs();
//根据策略ID号,从数据库中获取策略内容的详细信息
aplcoms.preparedQuery("");
aplcoms.setString(1 ,policyId);
SysResultSet rs = aplcoms.csCommonQuery("SQL_Agt_PolicyQueryDetail" ,"1" ,"-1").getResultSet();
//由于策略内容为多条记录,所以把结果集存放到session中
//req.getSession().setAttribute("POLICY-QUERY-CONTENTSET",rs);
req.setAttribute("POLICY-QUERY-CONTENTSET",rs);
req.setAttribute("POLICYID",policyId);
//定向
if(opeType.equalsIgnoreCase(OperatorFlagCode.POLICY_QDETAIL_SHOW))
{ //定向到列表显示页面
return (mapping.findForward("policydetail"));
}
else
{//操作类型为查询详细信息-为了修改
return (mapping.findForward("policymodify"));
}
}
catch (SysDbException aple)
{//捕获CommonService系统异常,定向到出错页面
//输出异常信息
aple.printStackTrace();
req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
return (mapping.findForward("error"));
}
catch(java.sql.SQLException sqle)
{//捕获调用aplcoms异常,定向到出错页面
// 输出异常信息
sqle.printStackTrace();
req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
return (mapping.findForward("error"));
}
catch(Exception e)
{//捕获未知异常,定向到出错页面
//输出异常信息
e.printStackTrace();
req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
return (mapping.findForward("error"));
}
finally
{//关闭连接实例
if(aplcoms != null)
{
aplcoms.close();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?