java的数据传输流程

6 篇文章 0 订阅

1、首先是js发送一个post 或者get请求到controller
在这里插入图片描述
2、controller处理请求返回一个界面(这里并没有检查权限,当处理增删改操作时才检查是否有这个权限),即完成跳转界面操作

/**
 * 跳转到部门管理首页
 */
@RequestMapping("")
public String index() {
    return PREFIX + "dept.html";
}

3、界面加载时根据权限进行加载按钮
在这里插入图片描述
4、点击相应按钮后由js发送post,get请求到controller

eptInfoDlg.addSubmit = function () {
    var ajax = new $ax(Feng.ctxPath + "/dept/add", function (data) {
        parent.Feng.success("添加成功!");
        window.parent.Dept.table.refresh();
        DeptInfoDlg.close();
    }, function (data) {
        parent.Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(DeptInfoDlg.data);
    ajax.start();
};

5、controller通过service对象 : service->serviceImpl->mapper 然后通过orm框架
(mybatis-plus)进行映射mapper的函数以及实体类。然后controller返回的数据
通过spring mvc的 @ResponseBody 注解将数据变成JSON对象数据格式返回。

controller


@Autowired
private sendandreService sen;
/**
 * 获取所有收派标准列表
 */
@RequestMapping(value = "/listt")
@ResponseBody
public List<Map<String, Object>> list(@RequestParam(value = "sendName", required = false) String condition)
{
    List<Map<String, Object>> list = this.sen.list(condition);
    return list;
}

service

//得加个component,具体是为什么忘了,可以去掉试下(会出错)
@Component
public class sendandreService extends ServiceImpl<SendandreMapper, Sendandre> {
    /**
     * 获取收派列表
     */
    public List<Map<String, Object>> list(String condition) {
        return this.baseMapper.list(condition);
    }
    public List<Map<String, Object>> selectbyid(Long sendid) {
        return this.baseMapper.selectbyid(sendid);
    }
}

mapper

public interface SendandreMapper extends BaseMapper<Sendandre> {
    /**
     * 获取收派列表
     */
    List<Map<String, Object>> list(@Param("condition") String condition);

mapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bos.modular.system.mapper.SendandreMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.bos.modular.system.entity.Sendandre">
        <id column="id" property="sendid" />
        <result column="sendname" property="sendname" />
        <result column="minwe" property="minwe" />
        <result column="maxwe" property="maxwe" />
        <result column="operator" property="operatorid" />
        <result column="dotime" property="dotime" />
        <result column="dodept" property="dodeptid" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS sendid, sendname AS sendname, minwe, maxwe, operator AS operatorid, dotime, dodept AS dodeptid
    </sql>

    <select id="list" resultType="map">
        select
        <include refid="Base_Column_List"></include>
        from basic_sendandre
        <if test="condition != null and condition != ''">
            where sendname like CONCAT('%',#{condition},'%')
        </if>
        order by sendname
    </select>

<mapper>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值