1、select后的字段用关键字isnull解决结果为空的问题。
String sql="select isnull(sum(MZRC),0) as MZRC,isnull(sum(ZYRC),0) as ZYRC,isnull(sum(JZRC),0) as JZRC,isnull(sum(QTRC),0) as QTRC,isnull(sum(JCRC),0) as JCRC,isnull(sum(MZYXRC),0) as MZYXRC,isnull(sum(ZYYXRC),0) as ZYYXRC,isnull(sum(JZYXRC),0) as JZYXRC,isnull(sum(QTYXRC),0) as QTYXRC,isnull(sum(YXRC),0) as YXRC,isnull(sum(MZJCFY),0) as MZJCFY,isnull(sum(ZYJCFY),0) as ZYJCFY,isnull(sum(JZJCFY),0) as JZJCFY,isnull(sum(QTJCFY),0) as QTJCFY,isnull(sum(JCFY),0) as JCFY from TB_CUBE_DXSBTJ where NF_ID=? and SJ_ID=?";
2、先判断参数type是否为指定关键字,再通过判断type类型(type.equals("mzrc")→→("mzrc").equals(type)),拼接相应的检索语句。
3、后台获取前台参数
HttpServletRequest request=ServletActionContext.getRequest();
String type=request.getParameter("type");