POST请求时得到指数十进制值

时间:2018-10-23 05:22:05

标签: java spring rest

我有弹簧模型类,控制器。 在发布请求中,我将模型类值作为请求正文。 看看

Employee.java

@JsonInclude(Include.NON_NULL)
public class Employee {

private Number id;
@Size(message = "Size of field: field_name exceeds the maximum length: " + CommonConstants.name,max = CommonConstants.name)
@NotBlank(message="should not be null")
private String name;
@Size(max = CommonConstants.role, min=1, message = "length exceeds : role")
private String role;

public Number getId() {
    return id;
}

public void setId(Number id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getRole() {
    return role;
}

public void setRole(String role) {
    this.role = role;
}
}

EmployeeController.java

@RequestMapping(value = "/emp/save.do1",consumes = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.POST)
public String saveEmployeeAction(
        @Valid @RequestBody Employee employee,
        BindingResult bindingResult) {

    System.out.println(employee.getId());
    if (bindingResult.hasErrors()) {
        logger.info("Returning empSave.jsp page");


    return "empSave";
    }
}

当我从邮递员那里访问此API时,

{
"id": 10252305408629.14,
"name":"sdf",
"role": "ceo"
}

当我调试代码时,

我的员工编号为

1.025230540862914E13,数据类型为Double

我希望它像10252305408629.14之类的原始值,而不更改模型中的 Number 数据类型。

0 个答案:

没有答案