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();
}
}
结果:
transient修饰符的作用的更多相关文章
- Transient修饰符的使用
如果一个类没有继承Serilizable接口,那么它就不能被序列化,写入文件的时候会报异常.如果一个类继承了Serilizable接口,那么这个类的所有属性和方法都可以自动被序列化,而现实中我们又希望 ...
- C# Static修饰符的作用
MSDN上的定义 Use the static modifier to declare a static member, which belongs to the type itself rather ...
- python中的修饰符@的作用
1.一层修饰符 1)简单版,编译即实现 在一个函数上面添加修饰符 @另一个函数名 的作用是将这个修饰符下面的函数作为该修饰符函数的参数传入,作用可以有比如你想要在函数前面添加记录时间的代码,这样每个函 ...
- java 修饰符的作用一(public protected default private 组)
1.public protected default private 组 public 权限最大,同类,同包,不同包,同包子类父类之间,不同包子类父类之间都可以访问. java 默认的权限是defau ...
- java transient修饰符
1)一旦变量被transient修饰,变量将不再是对象持久化的一部分,该变量内容在序列化后无法获得访问. 2)transient关键字只能修饰变量,而不能修饰方法和类.注意,本地变量是不能被trans ...
- Python中@修饰符的作用。
'@'符号用作函数修饰符是python2.4新增加的功能,修饰符必须出现在函数定义前一行,不允许和函数定义在同一行.也就是说@A def f(): 是非法的. 只可以在模块或类定义层内对函数进行修饰, ...
- JAVA中几个修饰符的作用以及一些相关话题
几个传统的修饰符: public 该类的子类,以及同包,或者其他情况下可以访问该修饰符修饰的方法/变量 protacted 只有同包,子类,该类本身可以访问 private 只有该类自身能访问 无修饰 ...
- scanf函数中*修饰符的作用,如:%*d
在scanf函数中,*修饰符可以跳过所在项的输入.如下: #include <stdio.h> int main() { ; printf("请输入:"); scanf ...
- printf函数中*修饰符的作用,如:%*d
在printf函数中,我们可以用数字修饰来控制打印的字段宽度和精度,如下(为强调视觉效果,均填充0): #include <stdio.h> int main() { ; float f= ...
随机推荐
- DB-MySQL:MySQL 索引
ylbtech-DB-MySQL:MySQL 索引 1.返回顶部 1. MySQL 索引 MySQL索引的建立对于MySQL的高效运行是很重要的,索引可以大大提高MySQL的检索速度. 打个比方,如果 ...
- HTML iframe 和 frameset 的区别
转自:http://www.cnblogs.com/polk6/archive/2013/05/24/3097430.html HTML iframe 和 frameset 的区别 iframe 和 ...
- 使用右键打开Visual Code
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\Visual Code]@="Edit with Visual ...
- 调试相关blogs收集
Debug Diag官方blog https://blogs.msdn.microsoft.com/debugdiag/ Tess https://blogs.msdn.microsoft.com ...
- 欢迎来到Flask的世界
不多说,直接上文档链接:Flask的文档 教程 API 快速上手
- Sentry: Python 实时日志平台
Links https://docs.getsentry.com/on-premise/quickstart/ https://docs.getsentry.com/on-premise/server ...
- Qwiklab'实验-CloudFront, EFS, S3'
title: AWS之Qwiklab subtitle: 3. Qwiklab'实验-CloudFront, EFS, S3' date: 2018-09-21 17:29:20 --- Introd ...
- Pyhton学习——Day27
# hasattr(obj,'name')-->obj.name# getattr(obj,'name',default = 'xxx')--->obj.name# setattr(obj ...
- Maven学习总结(24)——Maven版本管理详解
Maven的版本分为快照和稳定版本,快照版本使用在开发的过程中,方便于团队内部交流学习.而所说的稳定版本,理想状态下是项目到了某个比较稳定的状态,这个稳定包含了源代码和构建都要稳定. 一.如何衡量项目 ...
- Maven简单介绍(Maven是什么)
简单介绍 Maven,在意第绪语中意为对知识的积累.Maven最初用来在Jakarta Turbine项目中简化该项目的构建过程. Jakarta Trubine项目有多个project.每一个pro ...