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端返回一个错误消息提醒用户}
    }

      

  • 相关阅读:
    singleTon 模式
    最近的工作经验
    sql server里的快捷键
    Bridge 模式
    [转]在.NET客户端程序中使用多线程
    wse
    关于高频查询界面
    判断字段值已经存在
    获取当前供应商的联系人信息
    获取系统常量
  • 原文地址:https://www.cnblogs.com/ipetergo/p/6755067.html
Copyright © 2011-2022 走看看