serviceimpl
业务实现层
package com.example.demo4.service; import com.example.demo4.userBean.userBean; import com.example.demo4.userDao.UserDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; @Service public class servielimpl implements service { @Autowired private UserDao userDao; @Override public List<userBean> select(Map<String, Object> userMap) { return userDao.select(userMap); } }
testController 直接访问返回
package com.example.demo4.Controller; import com.example.demo4.service.service; import com.example.demo4.userBean.userBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; //@Controller @RestController public class testController { @Autowired private service service; @RequestMapping("/aaa") public String sayHello() { return "helloword"; }
testController 直接查询数据库数据
package com.example.demo4.Controller; import com.example.demo4.service.service; import com.example.demo4.userBean.userBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; //@Controller @RestController public class testController { @Autowired private service service; @RequestMapping("/aaa") public String sayHello() { return "helloword"; } @RequestMapping(value = "/fu") @ResponseBody public List<userBean> fuzzyCUser(HttpServletRequest request) { Map<String,Object> result = new HashMap<>(); List<userBean>list =service.select(result); // result.put("list",list); request.getSession().setAttribute("LIST",list); // return result; return list; }
testController 访问list输出的数据
package com.example.demo4.Controller; import com.example.demo4.service.service; import com.example.demo4.userBean.userBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; //@Controller @RestController public class testController { @Autowired private service service; @RequestMapping("/aaa") public String sayHello() { return "helloword"; } // @RequestMapping(value = "/fu") // @ResponseBody // public List<userBean> fuzzyCUser(HttpServletRequest request) { // Map<String,Object> result = new HashMap<>(); // List<userBean>list =service.select(result); // // result.put("list",list); // request.getSession().setAttribute("LIST",list); // // return result; // return list; // // // } @RequestMapping(value = "/fuss") @ResponseBody public Map<String,Object> fuzzyCUser(HttpServletRequest request) { Map<String, Object> result = new HashMap<>(); List<userBean> list = service.select(result); result.put("list", list); request.getSession().setAttribute("LIST", list); return result; } }
这样查询就出来了 大家有意见和问题的可以提出来 欢迎讨论。
一个新手、没背景的野鸡大学挣脱出来的野小子,主要以不断
学习,不断记录,用思维认知去看这个世界。写作、阅读、分享,用独自的思考和感悟分享给互联网里的每一位技术人。
不爱学习的我们,无力的挣扎吧!