| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1560 人关注过本帖
标题:action疑问
只看楼主 加入收藏
liyang220422
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-6-15
收藏
 问题点数:0 回复次数:0 
action疑问
    //分页查询
    @RequestMapping(params="method=prefindByPage")
    public ModelAndView prefindByPage(Student stu, HttpServletRequest request, HttpServletResponse response){
        System.out.println(stu.getSt_name());
        Map<String,Object> mapValue = new HashMap<String,Object>();
        mapValue.put("st_name", stu.getSt_name());
        mapValue.put("st_tel",stu.getSt_tel());
        mapValue.put("invite", stu.getInvite());
        mapValue.put("st_QQ", stu.getSt_QQ());
        mapValue.put("st_wechat", stu.getSt_wechat());
        mapValue.put("St_purpose", stu.getSt_purpose());
        String sTime = request.getParameter("consultTimeStart");
        mapValue.put("consultTimeStart", sTime);
        String eTime = request.getParameter("consultTimeEnd");
        mapValue.put("consultTimeEnd", eTime);
        List rows = this.getStudentService().findByPage("student.prefindByPage", mapValue);
        
        int totalRows = rows.size();//查询总记录数(8个条件)
        
        PageBean pageBean = PagerHelp.getPager(request, totalRows);
        
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("pageSize", pageBean.getPageSize());
        map.put("currentPage", pageBean.getCurrentPage());
        
        map.put("st_name", stu.getSt_name());
        map.put("st_tel",stu.getSt_tel());
        map.put("invite", stu.getInvite());
        map.put("st_QQ", stu.getSt_QQ());
        map.put("st_wechat", stu.getSt_wechat());
        map.put("St_purpose", stu.getSt_purpose());
        String startTime = request.getParameter("consultTimeStart");
        map.put("consultTimeStart", startTime);
        String endTime = request.getParameter("consultTimeEnd");
        map.put("consultTimeEnd", endTime);
        
        List list = this.getStudentService().findByPage("student.findByPage", map);
        request.setAttribute("stuList",list);
        request.setAttribute("pageBean",pageBean);
        request.setAttribute("stu",stu);
        request.setAttribute("purpose", stu.getSt_purpose());
        request.setAttribute("consultTimeStart",startTime);
        request.setAttribute("consultTimeEnd",endTime);
        return new ModelAndView("studentInfo/consult_studentInfo_visit");
    }
   
    @RequestMapping(params="method=findByPage")
    public ModelAndView findByPage(Student stu, HttpServletRequest request, HttpServletResponse response) throws Exception{
        System.out.println(stu.getSt_name());
        Map<String,Object> mapValue = new HashMap<String,Object>();
        String zd = request.getParameter("st_name");
        zd =  new String(zd.getBytes("ISO-8859-1"),"UTF-8");
        stu.setSt_name(zd);
        mapValue.put("st_name",stu.getSt_name());
        mapValue.put("st_tel",stu.getSt_tel());
        String zd1 = request.getParameter("invite");
        zd1 =  new String(zd1.getBytes("ISO-8859-1"),"UTF-8");
        stu.setInvite(zd1);
        mapValue.put("invite", stu.getInvite());
        mapValue.put("st_QQ", stu.getSt_QQ());
        String zd2 = request.getParameter("st_wechat");
        zd2 =  new String(zd2.getBytes("ISO-8859-1"),"UTF-8");
        mapValue.put("st_wechat", stu.getSt_wechat());
        String zd3 = request.getParameter("St_purpose");
        zd3=  new String(zd3.getBytes("ISO-8859-1"),"UTF-8");
        stu.setSt_purpose(zd3);
        mapValue.put("St_purpose", stu.getSt_purpose());
        String sTime = request.getParameter("consultTimeStart");
        mapValue.put("consultTimeStart", sTime);
        String eTime = request.getParameter("consultTimeEnd");
        mapValue.put("consultTimeEnd", eTime);
        List rows = this.getStudentService().findByPage("student.prefindByPage", mapValue);
        
        int totalRows = rows.size();//查询总记录数(8个条件)
        PageBean pageBean = PagerHelp.getPager(request, totalRows);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("pageSize", pageBean.getPageSize());
        map.put("currentPage", pageBean.getCurrentPage());
        
        map.put("st_name", stu.getSt_name());
        map.put("st_tel",stu.getSt_tel());
        map.put("invite", stu.getInvite());
        map.put("st_QQ", stu.getSt_QQ());
        map.put("st_wechat", stu.getSt_wechat());
        map.put("St_purpose", stu.getSt_purpose());
        String startTime = request.getParameter("consultTimeStart");
        map.put("consultTimeStart", startTime);
        String endTime = request.getParameter("consultTimeEnd");
        map.put("consultTimeEnd", endTime);
        
        List list = this.getStudentService().findByPage("student.findByPage", map);
        request.setAttribute("stuList",list);
        request.setAttribute("pageBean",pageBean);
        request.setAttribute("ConsultStudent",stu);
        request.setAttribute("purpose", stu.getSt_purpose());
        request.setAttribute("consultTimeStart",startTime);
        request.setAttribute("consultTimeEnd",endTime);
        return new ModelAndView("studentInfo/consult_studentInfo_visit");
    }
这是一个分页时用到的,点击查询调用第一个方法,点击翻页调用第二个方法,但是为何第一个方法里面传递的对象就是正常值,而第二个方法传递的值却需要转换,否则传到后台就变成乱码了,有点想不通
搜索更多相关主题的帖子: request Map stu String put 
2017-09-09 23:44
快速回复:action疑问
数据加载中...
 
   



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

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