在springmvc+mybatis中,返回用@responsebody自动处理json,默认使用的是Jackson解析。Jackson在解析返回的json字符串时始首字母是小写
解决办法:在get方法上增加@JsonProperty注解
- public class OaUserEntity {
- // 员工姓名
- private String RealName;
- // 登录ID
- private String LoginID;
- // 部门ID
- private String DepartmentCode1;
- // 部门全路径
- private String FullName;
- @JsonProperty("RealName")
- public String getRealName() {
- return RealName;
- }
- public void setRealName(String realName) {
- RealName = realName;
- }
- @JsonProperty("LoginID")
- public String getLoginID() {
- return LoginID;
- }
- public void setLoginID(String loginID) {
- LoginID = loginID;
- }
- @JsonProperty("DepartmentCode1")
- public String getDepartmentCode1() {
- return DepartmentCode1;
- }
- public void setDepartmentCode1(String departmentCode1) {
- DepartmentCode1 = departmentCode1;
- }
- @JsonProperty("FullName")
- public String getFullName() {
- return FullName;
- }
- public void setFullName(String fullName) {
- FullName = fullName;
- }
- }