| 网站首页 | 业界新闻 | 群组 | 人才 | 技术文章 | 下载频道 | 博客 | 代码贴 | 编程论坛
绝地游戏外挂辅助教学千里之行 始于足下
共有 1313 人关注过本帖
标题:哪位高手帮忙给看一下,我的查询功能一直实现不了 ????谢谢
只看楼主 收藏
ggskyle
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-24
结帖率:0
  已结贴   问题点数:20  回复次数:12   
哪位高手帮忙给看一下,我的查询功能一直实现不了 ????谢谢
这是查询的主界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息管理</title>
<script type="text/javascript">
var url;
//打开新增患者对话框
function openPatientAddDialog(){
    //在勾选情况下点击新增要先清除数据
    resetValue();
    $("#dlg").dialog("open").dialog("setTitle","添加患者信息");
    url="patient!save";//为url赋值
}
//重置对话框内数据
function resetValue(){
    $("#patientName").val("");
    $("#zhuangtai").combobox("setValue","");
    $("#birthday").datebox("setValue","");
    $("#chuli").datebox("setValue","");
    $("#patientDesc").val("");
    $("#didian").combobox("setValue","");
    $("#jielun").combobox("setValue","");
    $("#tel").val("");
    $("#money").val("");
    $("#baoxiao").val("");

}
//关闭对话框
function closePatientDialog(){
    $("#dlg").dialog("close");
    resetValue();
}
//提交新增患者数据
function savePatient(){
    $("#fm").form("submit",{
        url:url,
        onSubmit:function(){
            if($('#zhuangtai').combobox("getValue")==""){
                $.messager.alert("系统提示","请选择手续状态");
                return false;
            }
            if($('#didian').combobox("getValue")==""){
                $.messager.alert("系统提示","请选择调查地点");
                return false;
            }
            return $(this).form("validate");
        },
        success:function(result){
            if(result.errorMsg){
                $.messager.alert("系统提示",result.errorMsg);
                return;
            }else{
                $.messager.alert("系统提示","保存成功");
                resetValue();
                $("#dlg").dialog("close");
                $("#dg").datagrid("reload");
            }
        }
    });
}
//删除选中的患者数据
function deletePatient(){
    //获得选中数据对象
    var selectedRows=$("#dg").datagrid('getSelections');
    if(selectedRows.length==0){
        $.messager.alert("系统提示","请选择要删除的数据!");
        return;
    }
    var strIds=[];//要删除的序号组合
    for(var i=0;i<selectedRows.length;i++){
        strIds.push(selectedRows[i].patientId);
    }
    var ids=strIds.join(",");
    $.messager.confirm("系统提示","您确认要删掉这<font color=red>"+selectedRows.length+"</font>条数据吗?",function(r){
        if(r){
            //ajax提交 delIds
            $.post("patient!delete",{delIds:ids},function(result){
                if(result.success){
                    $.messager.alert("系统提示","您已成功删除<font color=red>"+result.delNums+"</font>条数据!");
                    $("#dg").datagrid("reload");
                }else{
                    $.messager.alert('系统提示',result.errorMsg);
                }
            },"json");
        }
    });
}
//修改患者资料
function openPatientModifyDialog(){
    var selectedRows=$("#dg").datagrid('getSelections');
    if(selectedRows.length!=1){
        $.messager.alert("系统提示","请选择一条要编辑的数据!");
        return;
    }
    var row=selectedRows[0];
    $("#dlg").dialog("open").dialog("setTitle","编辑患者资料");
    $("#patientName").val(row.patientName);
    $("#zhuangtai").combobox("setValue",row.zhuangtai);
    $("#birthday").datebox("setValue",row.birthday);
    $("#chuli").datebox("setValue",row.chuli);
    $("#patientDesc").val(row.patientDesc);
    $("#didian").combobox("setValue",row.didian);
    $("#jielun").combobox("setValue",row.jielun);
    $("#tel").val(row.tel);
    $("#money").val(row.money);
    $("#baoxiao").val(row.baoxiao);
    url="patient!save?patientId="+row.patientId;
}
//查询符合条件的用户
function searchPatient(){
    $('#dg').datagrid('load',{
        s_patientName:$('#s_patientName').val(""),
        zhuang:$('#zhuang').combobox("getValue"),
        jie:$('#jie').combobox("getValue"),
    });
}
//倒出excel数据
function exportPatient(){
    $('#export').form("submit",{
        url:"patient!exportPatient"
    })
    //window.location.href="employee!ExportEmployee";
}
</script>
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
</head>
<body style="margin:5px">
<table id="dg" title="患者信息" class="easyui-datagrid" fitColumns="true"
     pagination="true" rownumbers="true" url="patient" fit="true" toolbar="#tb">
        <thead>
            <tr>
                <th field="cb" checkbox="true"></th>
                <th field="patientId" width="40"  align="center">编号</th>
                <th field="patientName" width="80"  align="center">患者名称</th>
                <th field="zhuangtai" width="80"  align="center">手续状态</th>
                <th field="didian" width="80"  align="center">调查地点</th>
                <th field="jielun" width="80" align="center">调查结论 </th>
                <th field="birthday" width="80" align="center">调查日期</th>
                <th field="chuli" width="80" align="center">处理日期</th>
                <th field="tel" width="80" align="center">联系电话</th>
                <th field="patientDesc" width="250" align="center">家庭住址</th>
                <th field="money" width="80" align="center">花费金额</th>
                <th field="baoxiao" width="80" align="center">报销金额</th>
               
               
            </tr>
        </thead>
    </table>
    <div id="tb">
        <div>
            <a href="javascript:openPatientAddDialog()" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
            <a href="javascript:openPatientModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
            <a href="javascript:deletePatient()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
            <a href="javascript:exportPatient()" class="easyui-linkbutton" iconCls="icon-export" plain="true">导出Execl</a>
        </div>
        <div>
            <form id="export" method="post">
            &nbsp;姓名:&nbsp;<input type="text" name="s_patientName" id="s_patientName" size="10"/>
            &nbsp;手续状态:&nbsp;<select  id="zhuang" name="zhuang" editable="false" panelHeight="auto" style="width: 155px">
                        <option value="">请选择...</option>
                        <option value="未调">未调</option>
                        <option value="已调">已调</option>
                    </select>
            &nbsp;调查结论:&nbsp;<select  id="jie" name="jie" editable="false" panelHeight="auto" style="width: 155px">
                        <option value="">请选择...</option>
                        <option value="正常">正常</option>
                        <option value="侧调">侧调</option>
                        <option value="拒赔">拒赔</option>
                    </select>
            <a href="javascript:searchPatient()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
            </form>
        </div>
    </div>
        
    <div id="dlg" class="easyui-dialog" style="width: 570px;height: 340px;padding: 10px 20px"
        closed="true" buttons="#dlg-buttons">
        <form id="fm" method="post" enctype="multipart/form-data">
            <table cellspacing="5px;">
                <tr>        
                    <td>患者姓名:</td>
                    <td><input type="text" name="patient.patientName" id="patientName" class="easyui-validatebox" required/></td>
                    <td>手续状态:</td>
                    <td><select class="easyui-combobox" id="zhuangtai" name="patient.zhuangtai" editable="false" panelHeight="auto" style="width: 155px">
                        <option value="">请选择...</option>
                        <option value="未调">未调</option>
                        <option value="已调">已调</option>
                    </select></td>
                </tr>
                <tr>
                    <td>调查地点:</td>
                    <td><select class="easyui-combobox" id="didian" name="patient.didian" editable="false" panelHeight="auto" style="width: 155px">
                        <option value="">请选择...</option>
                        <option value="医院">医院</option>
                        <option value="实地">实地</option>
                        <option value="公司">公司</option>
                        <option value="无">无</option>
                    </select></td>
                    <td>调查结论:</td>
                    <td><select class="easyui-combobox" id="jielun" name="patient.jielun" editable="false" panelHeight="auto" style="width: 155px">
                        <option value="">请选择...</option>
                        <option value="正常">正常</option>
                        <option value="侧调">侧调</option>
                        <option value="拒赔">拒赔</option>
                        <option value="无">无</option>
                    </select></td>
                </tr>
                <tr>
                <td>调查日期:</td>
                    <td><input class="easyui-datebox" name="patient.birthday" id="birthday" required editable="false" /></td>
                    <td>处理日期:</td>
                    <td><input class="easyui-datebox" name="patient.chuli" id="chuli" required editable="false" /></td>
            
               
                </tr>
                <tr>        
                    <td>花费金额:</td>
                    <td><input type="text" name="patient.money" id="money" class="easyui-validatebox" required/></td>
                    <td>报销金额:</td>
                    <td><input type="text" name="patient.baoxiao" id="baoxiao"  required/></td>
                    </tr>
                    <tr>        
                    <td>联系电话:</td>
                    <td><input type="text" name="patient.tel" id="tel" class="easyui-validatebox" required/></td>
                    </tr>
                <tr>
                    <td valign="top">家庭住址:</td>
                    <td colspan="4"><textarea rows="7" cols="46" name="patient.patientDesc" id="patientDesc"></textarea></td>
                </tr>
            </table>
        </form>
    </div>
   
    <div id="dlg-buttons">
        <a href="javascript:savePatient()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
        <a href="javascript:closePatientDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
    </div>
</body>
</html>

Dao.java:
package org.com.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.com.model.PageBean;
import org.com.model.Patient;
import org.com.util.DateUtil;
import org.com.util.StringUtil;

public class PatientDao {
    /**
     * 得到patient查询结果
     * @param con
     * @param pageBean
     * @param patient
     * @return
     * @throws Exception
     */
    public ResultSet patientList(Connection con,PageBean pageBean,Patient patient,String zhuang,String jie)throws Exception{
        StringBuffer sb=new StringBuffer("select * from t_patient");
        
        if(StringUtil.isNotEmpty(patient.getPatientName())){
            sb.append(" and patientName like '%"+patient.getPatientName()+"%'");
        }
        
        //分页
        if(pageBean!=null){
            sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows());
        }
        PreparedStatement pstmt=con.prepareStatement(sb.toString());
        return pstmt.executeQuery();
    }
    /**
     * 获取数据总条数
     * @param con
     * @param grade
     * @return
     * @throws Exception
     */
    public int patientCount(Connection con,Patient patient,String zhuang,String jie)throws Exception{
        StringBuffer sb=new StringBuffer("select count(*) as total from t_patient");
        
        if(StringUtil.isNotEmpty(patient.getPatientName())){
            sb.append(" and patientName like '%"+patient.getPatientName()+"%'");
        }
        
        PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs=pstmt.executeQuery();
        if(rs.next()){
            return rs.getInt("total");
        }else{
            return 0;
        }
    }
    /**
     * 数据库插入数据
     * @param con
     * @param patient
     * @return
     * @throws Exception
     */
    public int patientAdd(Connection con,Patient patient)throws Exception{
        String sql="insert into t_patient values(null,?,?,?,?,?,?,?,?,?,?)";
        PreparedStatement pstmt=con.prepareStatement(sql);
        pstmt.setString(1, patient.getPatientName());
        pstmt.setString(2, patient.getZhuangtai());
        pstmt.setString(3, DateUtil.formatDate(patient.getChuli(), "yyyy-MM-dd"));
        pstmt.setString(4, DateUtil.formatDate(patient.getBirthday(), "yyyy-MM-dd"));
        pstmt.setString(5, patient.getDidian());
        pstmt.setString(6, patient.getJielun());
        pstmt.setString(7, patient.getTel());
        pstmt.setString(8, patient.getPatientDesc());
        pstmt.setString(9, patient.getMoney());
        pstmt.setString(10, patient.getBaoxiao());
        return pstmt.executeUpdate();
    }
   
   
    /**
     * 删除数据
     * @param con
     * @param delIds
     * @return
     * @throws Exception
     */
    public int patientDelete(Connection con,String delIds)throws Exception{
        String sql="delete from t_patient where patientId in("+delIds+")";
        PreparedStatement pstmt=con.prepareStatement(sql);
        return pstmt.executeUpdate();
    }
    /**
     * 患者资料更改
     * @param con
     * @param patient
     * @return
     * @throws Exception
     */
    public int patientModify(Connection con,Patient patient)throws Exception{
        String sql="update t_patient set patientName=?,zhuangtai=?,birthday=?,chuli=?,didian=?,jielun=?,tel=?,patientDesc=?,money=?,baoxiao=? where patientId=?";
        PreparedStatement pstmt=con.prepareStatement(sql);
        pstmt.setInt(11, patient.getPatientId());
        pstmt.setString(1, patient.getPatientName());
        pstmt.setString(2, patient.getZhuangtai());
        pstmt.setString(3, DateUtil.formatDate(patient.getChuli(), "yyyy-MM-dd"));
        pstmt.setString(4, DateUtil.formatDate(patient.getBirthday(), "yyyy-MM-dd"));
        pstmt.setString(5, patient.getDidian());
        pstmt.setString(6, patient.getJielun());
        pstmt.setString(7, patient.getTel());
        pstmt.setString(8, patient.getPatientDesc());
        pstmt.setString(9, patient.getMoney());
        pstmt.setString(10, patient.getBaoxiao());
        
        return pstmt.executeUpdate();
    }
}


Avtion.java:
package org.com.action;


import java.io.OutputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.com.dao.PatientDao;
import org.com.dao.UserDao;
import org.com.model.PageBean;
import org.com.model.Patient;
import org.com.model.User;
import org.com.util.DateUtil;
import org.com.util.DbUtil;
import org.com.util.JsonUtil;
import org.com.util.ResponseUtil;
import org.com.util.StringUtil;

import com.opensymphony.xwork2.ActionSupport;

public class PatientAction extends ActionSupport implements ServletRequestAware{
   
    private Patient patient;//patient对象
    private String page;//分页数据
    private String rows;//分页数据
    private String delIds;//批量删除数据的序列号
    private String patientId;//修改患者资料传递的患者编号
    //查询条件的变量
    private String s_patientName;
    private String zhuang;
    private String jie;
   
   
    public String getPage() {
        return page;
    }
    public void setPage(String page) {
        this.page = page;
    }
   
    public String getRows() {
        return rows;
    }
    public void setRows(String rows) {
        this.rows = rows;
    }
   
    public Patient getPatient() {
        return patient;
    }
    public void setPatient(Patient patient) {
        this.patient = patient;
    }   
    public String getDelIds() {
        return delIds;
    }
    public void setDelIds(String delIds) {
        this.delIds = delIds;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getS_patientName() {
        return s_patientName;
    }
    public void setS_patientName(String s_patientName) {
        this.s_patientName = s_patientName;
    }
    public String getZhuang() {
        return zhuang;
    }
    public void setZhuang(String zhuang) {
        this.zhuang = zhuang;
    }
    public String getJie() {
        return jie;
    }
    public void setJie(String jie) {
        this.jie = jie;
    }
   



    DbUtil dbUtil=new DbUtil();
    UserDao userDao=new UserDao();
    PatientDao patientDao=new PatientDao();
    HttpServletRequest request;
    //当前用户
    User currentUser;
   
   
    @Override
    public String execute() throws Exception {
        // 获取Session
        HttpSession session=request.getSession();   
        //链接connection
        Connection con=null;
        PageBean pageBean=new PageBean(Integer.parseInt(page),Integer.parseInt(rows));//分页pageBean
        if(patient==null){
            patient=new Patient();
        }
        
        if(s_patientName!=null){
            patient.setPatientName(s_patientName);
            patient.setZhuangtai(zhuang);
            patient.setJielun(jie);
        }
        try{
            con=dbUtil.getCon();
            JSONObject result=new JSONObject();
            JSONArray jsonArray=JsonUtil.formatRsToJsonArray(patientDao.patientList(con, pageBean,patient,zhuang,jie));
            int total=patientDao.patientCount(con,patient,zhuang,jie);
            result.put("rows", jsonArray);
            result.put("total", total);
            ResponseUtil.write(ServletActionContext.getResponse(), result);
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                dbUtil.closeCon(con);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
    //保存患者数据(新增和修改)
    public String save()throws Exception{
        //判断patientId是否为空
        if(StringUtil.isNotEmpty(patientId)){
            patient.setPatientId(Integer.parseInt(patientId));
        }
        Connection con=null;
        try{
            con=dbUtil.getCon();
            int saveNums=0;
            JSONObject result=new JSONObject();
            if(StringUtil.isNotEmpty(patientId)){
            //不为空,修改患者信息
                saveNums=patientDao.patientModify(con, patient);
            }else{
            //patientId为空,新增患者
                saveNums=patientDao.patientAdd(con, patient);
            }
            if(saveNums>0){
                result.put("success", "true");
            }else{
                result.put("success", "true");//业务逻辑,需要返回success,但返回的是错误message
                result.put("errorMsg", "保存失败");
            }
            ResponseUtil.write(ServletActionContext.getResponse(), result);
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                dbUtil.closeCon(con);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
    //删除数据
    public String delete()throws Exception{
        Connection con=null;
        try{
            con=dbUtil.getCon();
            JSONObject result=new JSONObject();
            int delNums=patientDao.patientDelete(con, delIds);
            if(delNums>0){
                result.put("success", "true");
                result.put("delNums", delNums);
            }else{
                result.put("errorMsg", "删除失败");
            }
            ResponseUtil.write(ServletActionContext.getResponse(), result);
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                dbUtil.closeCon(con);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
   
    //下拉框赋值 如果是管理员可以查询所有用户的患者,如果是用户只能显示当前用户患者
   
    //输出excel表格(xls)
    public void exportPatient() throws Exception{
        // 创建Excel的工作书册 Workbook,对应到一个excel文档
        HSSFWorkbook wb = new HSSFWorkbook();

        // 创建Excel的工作sheet,对应到一个excel文档的tab
        HSSFSheet sheet = wb.createSheet("sheet1");

        // 设置excel每列宽度
        sheet.setColumnWidth(0, 4000);
        sheet.setColumnWidth(1, 3500);

        // 创建字体样式
        HSSFFont font = wb.createFont();
        font.setFontName("Verdana");
        font.setBoldweight((short) 100);
        font.setFontHeight((short) 300);
        font.setColor(HSSFColor.BLUE.index);

        // 创建单元格样式
        HSSFCellStyle style = wb.createCellStyle();
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style.setFillForegroundColor(HSSFColor.LIGHT_TURQUOISE.index);
        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

        // 设置边框
        style.setBottomBorderColor(HSSFColor.RED.index);
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);

        style.setFont(font);// 设置字体
        style.setWrapText(true);// 自动换行

        // 创建Excel的sheet的一行
        HSSFRow row = sheet.createRow(0);
        row.setHeight((short) 500);// 设定行的高度
        HSSFCell cell=null;
        // 创建一个Excel的单元格
        String[] cellTitle = {"编号", "患者姓名", "手续状态","调查地点", "调查结论", "调查日期","处理日期","家庭住址"};   
        for (int i = 0; i < cellTitle.length; i++) {
            cell = row.createCell(i);
            // 给Excel的单元格设置样式和赋值
            cell.setCellStyle(style);
            cell.setCellValue(cellTitle[i]);
        }
        // 获取Session
        HttpSession session=request.getSession();   
        //链接connection
        Connection con=null;
        if(patient==null){
            patient=new Patient();
        }

        
        //将查询条件赋值给patient对象
        if(s_patientName!=null){
            patient.setPatientName(s_patientName);
            patient.setZhuangtai(zhuang);
            patient.setJielun(jie);
        }
        ResultSet rs=null;
        try{
            con=dbUtil.getCon();
            rs=patientDao.patientList(con, null,patient,zhuang,jie);
            int rowIndex=1;
            while(rs.next()){
                row = sheet.createRow(rowIndex++);
                cell = row.createCell(0);
                cell.setCellValue(rs.getInt("patientId"));
                cell = row.createCell(1);
                cell.setCellValue(rs.getString("patientName"));
                cell = row.createCell(2);
                cell.setCellValue(rs.getString("zhuangtai"));
                cell = row.createCell(3);
                cell.setCellValue(rs.getString("didian"));
                cell = row.createCell(4);
                cell.setCellValue(rs.getString("jielun"));
                cell = row.createCell(5);
                cell.setCellValue(rs.getString("birthday"));
                cell = row.createCell(6);
                cell.setCellValue(rs.getString("chuli"));
                cell = row.createCell(7);
                cell.setCellValue(rs.getString("patientDesc"));
               
            }
            
        String exportFileName = "patient.xls";
        
        ServletActionContext.getResponse().setHeader("Content-Disposition", "attachment;filename=" + new String((exportFileName).getBytes(), "ISO8859-1"));//设定输出文件头
        ServletActionContext.getResponse().setContentType("application/vnd.ms-excel;charset=UTF-8");// 定义输出类型
        
        
        OutputStream out = ServletActionContext.getResponse().getOutputStream();
        wb.write(out);
        out.flush();
        out.close();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                dbUtil.closeCon(con);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
        }
    }
        
        
    @Override
    public void setServletRequest(HttpServletRequest request) {
        // TODO Auto-generated method stub
        this.request=request;
   查询的功能就是实现不了   也不知道哪的问题    各位大神帮帮忙看看  谢谢

[此贴子已经被作者于2017-6-24 23:35编辑过]

搜索更多相关主题的帖子: 对话框  PUBLIC  content  function  javascript  
2017-06-24 23:34
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:74
帖 子:1390
专家分:5957
注 册:2015-3-19
  得分:10 
程序代码:
/**
     * 得到patient查询结果
     *
@param con
     *
@param pageBean
     *
@param patient
     *
@return
     *
@throws Exception
     
*/
    public ResultSet patientList(Connection con,PageBean pageBean,Patient patient,String zhuang,String jie)throws Exception{
        StringBuffer sb=new StringBuffer("select * from t_patient");
        
        if(StringUtil.isNotEmpty(patient.getPatientName())){
            sb.append(" and patientName like '%"+patient.getPatientName()+"%'");
        }
        
        //分页
        if(pageBean!=null){
            sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows());
        }
        PreparedStatement pstmt=con.prepareStatement(sb.toString());
        return pstmt.executeQuery();
    }

是这个查询吗?

like wind.
2017-06-25 09:52
ggskyle
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-24
  得分:0 
回复 2楼 林月儿
对呀!不知道怎么回事!
2017-06-25 19:12
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:74
帖 子:1390
专家分:5957
注 册:2015-3-19
  得分:0 
回复 3楼 ggskyle
先试试sql语句对不对 ,再debug调试看看调用sql语句的参数是否正常

like wind.
2017-06-25 19:16
ggskyle
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-24
  得分:0 
回复 4楼 林月儿
sql语句我试过没有问题   因是自学debug我不太会用  我能给您发过去整个项目,您帮忙给看看行么  

[此贴子已经被作者于2017-6-25 23:05编辑过]

2017-06-25 23:03
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:74
帖 子:1390
专家分:5957
注 册:2015-3-19
  得分:0 
回复 5楼 ggskyle
可以吧,不会再问问前辈

like wind.
2017-06-25 23:14
ggskyle
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-24
  得分:0 
回复 6楼 林月儿
谢谢了   我就用了其中的patientInfoManage的板块  其他的没有用

[此贴子已经被作者于2017-6-25 23:35编辑过]

附件: 您没有浏览附件的权限,请 登录注册
2017-06-25 23:32
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:74
帖 子:1390
专家分:5957
注 册:2015-3-19
  得分:0 
回复 7楼 ggskyle
初步测了下dao层的方法,没什么问题。试着传null值进去,报空指针异常。这个可能性排查清楚再说吧。

提些建议
变量名命名还是要有意义的好
异常处的处理最好打log
dao那边以及其他地方(比如excel等文件处理)共通程度还可以再高,而且上层接口也没写,建议改成接口定义加下层实现的常规写法。
数据解析处理json用的jar,建议换成gson.jar或版本更高
sql语句部分,关键字大小有交替出现,统一改为大写比较方便解析。

上面的建议偏后台,对后面的编码效率提高有帮助。
异常处理很重要,错误信息有迹可循

前台呢,可以效仿后台进行分层,按对象或功能分层。
ui的文件命名正式版本要调整了
js的操作可以写到js文件里,css样式定义到.css文件里。让jsp文件代码精简逻辑清晰
相应的请求,可以的话,struts.xml那边使用通配符减少action数量


[此贴子已经被作者于2017-6-26 09:55编辑过]


like wind.
2017-06-26 09:52
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:74
帖 子:1390
专家分:5957
注 册:2015-3-19
  得分:0 
先不管我提的建议,先实现功能吧。

[此贴子已经被作者于2017-6-26 20:38编辑过]


like wind.
2017-06-26 19:53
ggskyle
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-24
  得分:0 
呵呵  谢谢你的建议我会注意的  谢谢
关键是功能一直实现不了  呵呵  我的感觉是Dao层接受的赋值是空  
2017-06-26 22:39







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091921 second(s), 8 queries.
Copyright©2004-2017, BCCN.NET, All Rights Reserved