zoukankan      html  css  js  c++  java
  • ssm动态查询向前台传json

    1.数据协议层

    public User selectById(Integer id);//通过id值查询用户
    

    2.数据层

    <select id="selectById" resultType="com.yongxing.manager.domain.User">
     select * from user_inf where id=#{id}
    </select>
    

    3.服务协议层

    User findUserById(Integer id);
    

    4.服务开发层

    public User findUserById(Integer id) {
    		return userDao.selectById(id);
    	}
    

    5.控制层

    @RequestMapping("/user/selectUser/{id}")
    	@ResponseBody
    	public User getUserById(HttpSession session,@PathVariable int id){
    	        User user=userServcie.findUserById(id);
    	        return  user;
    	}
    

    注意:返回前台的是json数据

    6.使用postman测试接口

     

  • 相关阅读:
    linux
    网络编址
    抽象类 接口
    mysql
    java
    [lyu]Mysql解压版安装教程
    Mysql出现拒绝本地账户访问的情况副本
    js
    Redis限流和GeoHash
    布隆过滤器
  • 原文地址:https://www.cnblogs.com/cainame/p/10337537.html
Copyright © 2011-2022 走看看