易居主页点击登录跳转登录页面

易居主页点击登录跳转登录页面

UserController 中代码修改为

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("login.do")
    @ResponseBody
    public String login(@Param(value = "username") String username,
                        @Param(value = "password") String password){
        if ("123".equals(username)&&"123".equals(password)){
            return "success";
        }
        return "fail";
    }

    @RequestMapping("login1.do")
    @ResponseBody
    public String login1(@Param(value = "username") String username,
                        @Param(value = "password") String password){
        JSONObject jsonObject=new JSONObject();
        if ("123".equals(username)&&"123".equals(password)){
            jsonObject.put("result","1");
        }else {
            jsonObject.put("result","2");
        }
        return jsonObject.toString();
    }

    @RequestMapping("login2.do")
    @ResponseBody
    public String login2(@Param(value = "phone") String phone,
                         @Param(value = "password") String password){
        JSONObject jsonObject=new JSONObject();
        UserInfo user=userService.findUserByPhone(phone);
        if (user==null){
            jsonObject.put("result","0");
        }else if (!password.equals(user.getPassword())){
            jsonObject.put("result","1");
        }else {
            jsonObject.put("result","2");
        }
        return jsonObject.toString();
    }
}

新建接口IUserDao 接口中添加方法findUserByPhone

public interface IUserDao {
    UserInfo findUserByPhone(String phone);
}

Service新建接口IUserService 接口中也添加方法findUserByPhone

public interface IUserService {
    UserInfo findUserByPhone(String phone);
}

UserService中代码

@Service
public class UserService implements IUserService {

    @Autowired
    private IUserDao userDao;

    @Override
    public UserInfo findUserByPhone(String phone) {
        return userDao.findUserByPhone(phone);
    }
}

UserInfo中代码

package com.yiju.bean;

public class UserInfo {

    public UserInfo() {
    }
    public UserInfo(int userId, String nickname, String truename, int gender, String city, long createTime) {
        this.userId = userId;
        this.nickname = nickname;
        this.truename = truename;
        this.gender = gender;
        this.city = city;
        this.createTime = createTime;
    }

    private int userId; //用户id
    private String phone; //用户手机号,用于登录
    private String password; //密码
    private String email; //邮箱
    private String nickname; //昵称
    private String truename; //真实姓名
    private int gender; //性别 0:男 1:女
    private String province; //省份
    private String city; //城市
    private int isDelete; //是否删除 0:未删除 1:已删除
    private long createTime; //创建时间
    private long updateTime; //更新时间

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getTruename() {
        return truename;
    }

    public void setTruename(String truename) {
        this.truename = truename;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "userId=" + userId +
                ", phone='" + phone + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", nickname='" + nickname + '\'' +
                ", truename='" + truename + '\'' +
                ", gender=" + gender +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", isDelete=" + isDelete +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}

UserController 中代码

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("login.do")
    @ResponseBody
    public String login(@Param(value = "username") String username,
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值