How to customize the JSON for a certain class in SpringMVC

前端 未结 2 901
萌比男神i
萌比男神i 2021-01-27 08:09

I\'m using SpringMVC and have the following Method.

@RequestMapping(\"/login\")
public @ResponseBody User login(User user) {
    // some operation here ....
             


        
2条回答
  •  被撕碎了的回忆
    2021-01-27 08:59

    Spring uses Jackson to serialize and deserialize JSON by default. You can use Jackson's @JsonSerialize annotation on your User type and provider a JsonSerializer implementation which performs the serialization as you want it.

提交回复
热议问题