• 关于前端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>

  • 相关阅读:
    SAP OPEN UI5 Step 8: Translatable Texts
    SAP OPEN UI5 Step7 JSON Model
    SAP OPEN UI5 Step6 Modules
    SAP OPEN UI5 Step5 Controllers
    SAP OPEN UI5 Step4 Xml View
    SAP OPEN UI5 Step3 Controls
    SAP OPEN UI5 Step2 Bootstrap
    SAP OPEN UI5 Step1 环境安装和hello world
    2021php最新composer的使用攻略
    Php使用gzdeflate和ZLIB_ENCODING_DEFLATE结果gzinflate报data error
  • 原文地址:https://www.cnblogs.com/pureray-hui/p/12784497.html
Copyright © 2020-2023  润新知