zoukankan      html  css  js  c++  java
  • mybatis 控制器注解介绍(一)

    @RequestMapping("LoginController")
    public class LoginController { // 路径参数{name}填入用户名,{pass}填入密码。我们设置为GET请求。
    @RequestMapping(value ="/login_get.json/{name}/{pass}", method = RequestMethod.GET)
    @ResponseBody
    // 当使用@RequestMapping URI template 样式映射时, 即 /login_get.json/{name}/{pass},
    // 这时的name和pass可通过 @Pathvariable注解绑定它传过来的值到方法的参数上。
    public Object login(@PathVariable String name,@PathVariable String pass) {
    // 假如我们数据库里用户名是admin密码为123456
    if (name.equals("admin") && pass.equals("123456")) {
    // 到了这里就说明我们登录成功了,这时候我们就要给Android端返回这个用户的信息

    UserEntity entity = new UserEntity();
    entity.setUsername("admin");
    entity.setPassword("123456");
    entity.setNickname("张三");
    entity.setGender("男");
    entity.setAge("22"); return entity;// 此时返回此用户实体类} else {
    Map map = new HashMap();
    map.put("msg", "登录失败,请检查用户名和密码是否正确"); return map;// 登录失败给Android端返回一个错误消息提醒用户}
    }

      

  • 相关阅读:
    Makefile:2:*** missing separator. Stop.
    Code笔记之:对使用zend加密后的php文件进行解密
    Apache 访问控制
    leetcode-21-合并两个有序链表
    tcp四次挥手的过程
    实现一个LRU算法
    redis为什么快
    二月春日
    你的支持会鼓励我更积极地创作
    静夜思·静夜祈愿
  • 原文地址:https://www.cnblogs.com/ipetergo/p/6755067.html
Copyright © 2011-2022 走看看