zoukankan      html  css  js  c++  java
  • 关于前端ajax通过实体类向后端传参报不存在问题

    第一步:先获取到参数 (id)

    //控制层

    @Autowired

    DemoDemoService demoDemoService ;

    public Page<DemoDemoEntity > listData(DemoDemoEntity demoDemoEntity , HttpServletRequest request, HttpServletResponse response) {

     String id=demoEntity.getId();

    Page<DemoDemoEntity > page=new Page<>(request,response);

    psge.setPageSize(10); 

    page=demoDemoService .findfage(id);

    return page;}

    //业务层

    @Autowired

    DemoDao demoDao;

    public Page<DemoDemoEntity >  findfage(String id){

    Page<DemoDemoEntity > page=new Page<>();

     List<DemoDemoEntity > list=new List<>();

    //这里需要对id进行判断是否为blank,注意不是null

    if(StringUtils.isBlank(id)){

      list =demoDao.findAll();

    }else{

    list =demoDao.findOne(id);

    }

    page.setList(list);       //根据查询结果封装类型,也可以是map型

    return  page;

    }

    //数据层

    @Select(select * from demo group by xxx)

    List<DemoDemoEntity >  findAll();

    List<DemoDemoEntity >  findOne(@Param(id)String id);   //注意当在where内请添加@Param

    //xml文件内

    <resultMap type="XXXXX.XXXXX.XXXX.DemoEntity" id="自定义">
    <result property="id" column="id"/>
    <result property="demoTimes" column="demo_times"/>
    </resultMap>

    <select id="findone" parameterType="java.lang.String" resultMap="自定义(与上一致)">
    select a.id,count(create_time) as demoTimes from demo a
    <where>
    <if test="id!=null and id!=''">
    a.id=#{id}
    </if>
    GROUP BY a.id
    </where>
    </select>

  • 相关阅读:
    (转)堆与堆排序
    Cantor的数表
    Sticks(poj 1011)
    Square(hdu 1511)
    Fire Net(hdu 1045)
    Lake Counting(poj 2386)
    Ants (POJ 1852)
    A + B Problem II 大数加法
    深入理解计算机系统第二版家庭作业2.66
    C++ 队列queque/deque
  • 原文地址:https://www.cnblogs.com/pureray-hui/p/12784497.html
Copyright © 2011-2022 走看看