My App has a Web-Text input field. That data we store in the Database. When i show it again, the leading Whitespace are gone. I suspect the Jackson Object Mapper to make the mistake.
I use SpringBoot 3.0.6.
Input in the WebUI
In the Debugger of the Java application before mapping it to the UI-DTO.
In the Browser i see the following
The ObjectMapper looks like this:
@Bean
public ObjectMapper objectMapper() {
var objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
objectMapper.setSerializationInclusion(Include.NON_NULL);
var p = new DefaultPrettyPrinter();
Indenter i = new DefaultIndenter(" ", "\n");
p.indentArraysWith(i);
p.indentObjectsWith(i);
objectMapper.setDefaultPrettyPrinter(p);
return objectMapper;
}
Does somebody knows how to configure the ObjectMapper to keep the Whitespace?
I made a mistake. The Code is correct and the With space are preserved. Do ignore this Question.