zoukankan      html  css  js  c++  java
  • transient修饰符的作用

    transient修饰符的作用:

    entity实体类:

    package com.baidu.entity;
    
    import com.fasterxml.jackson.annotation.JsonIgnore;
    import org.springframework.data.annotation.Transient;
    
    import java.io.Serializable;
    
    public class User implements Serializable{
        private static final long serialVersionUID = 8121761080892505330L;
        private String username;
        @Transient
        @JsonIgnore
        private transient String password;
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    
        public String getPassword() {
            return password;
        }
    
        public void setPassword(String password) {
            this.password = password;
        }
    }

    Controller:

    @RequestMapping("/select")
        @ResponseBody
        public BaseResponse select(@RequestBody UserParam userParam){
            //用户重置
            userParam.setUsername("李雪雷2");
            userParam.setPassword("666662");
            try{
                List<User> users = userService.select();
                return BaseResponse.successCustom().setData(users).build();
            }catch (Exception e){
                e.printStackTrace();
                return BaseResponse.failedCustom("系统异常").build();
            }
        }

    结果:

  • 相关阅读:
    LeetCode之移除元素
    有被开心到hh(日常)
    交换排序
    插入排序
    顺序查找&折半查找
    C++之引用
    MySQL学习笔记
    C/C++程序编译过程
    计算机面试知识整合(更新中...)
    MFC之编辑框
  • 原文地址:https://www.cnblogs.com/super-chao/p/8393788.html
Copyright © 2011-2022 走看看