diff --git a/mvc/src/main/java/webmvc/org/springframework/web/servlet/view/JsonView.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/view/JsonView.java index d5d5ae72e7..070751ddf6 100644 --- a/mvc/src/main/java/webmvc/org/springframework/web/servlet/view/JsonView.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/view/JsonView.java @@ -10,7 +10,7 @@ public class JsonView implements View { - private final ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Override public void render(final Map model, final HttpServletRequest request, @@ -22,8 +22,8 @@ public void render(final Map model, final HttpServletRequest request, private String convertModel(final Map model) throws JsonProcessingException { if (model.size() == 1) { - return objectMapper.writeValueAsString(model.values().toArray()[0]); + return OBJECT_MAPPER.writeValueAsString(model.values().toArray()[0]); } - return objectMapper.writeValueAsString(model); + return OBJECT_MAPPER.writeValueAsString(model); } }