首页>代码>ssm(spring+spring mvc+mybatis)整合jquery实现手机二维码扫描登录项目实例>/ssm/src/main/java/cn/jsxwsl/maven/ssm/controller/UserController.java
package cn.jsxwsl.maven.ssm.controller; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import cn.jsxwsl.maven.ssm.bean.User; import cn.jsxwsl.maven.ssm.service.UserService; @Controller @RequestMapping("/user") public class UserController { @Autowired private UserService userService; // 返回页面 @RequestMapping("/{id}.html") public ModelAndView getUser(@PathVariable("id")long id){ ModelAndView md = new ModelAndView(); User user = userService.getUserById(id); md.addObject("user",user); md.setViewName("user"); return md; } // 返回json数据 @RequestMapping("/ujson/{id}") @ResponseBody public Map<String, Object> getUserJson(@PathVariable("id") long id ){ List<User> user = userService.getUserList(); Map<String, Object> map = new HashMap<>(); map.put("state", "success"); map.put("obj", user); return map; } @RequestMapping("/users.html") public ModelAndView getUserList(){ ModelAndView md = new ModelAndView(); // List<User> users = userService.getUserList(); // md.addObject("users",users); md.setViewName("user"); return md; } }
最近下载更多
newnu88 LV12
2023年10月26日
lcqlcl LV11
2023年8月29日
wmm500 LV3
2023年5月5日
renyuan LV9
2022年12月6日
1641426181 LV4
2022年3月11日
Q375892799 LV9
2022年3月3日
543666826 LV33
2021年11月19日
wyx065747 LV67
2021年7月9日
zhangkun545 LV1
2021年3月15日
孙家乐 LV3
2021年1月4日