我正在尝试自定义默认 Jackson 提供程序的行为。我写了如下代码,放到了war包里,但是还是不行。我正在使用 JBoss 版本 7.1.1.Final。
@javax.ws.rs.ext.Provider
@javax.ws.rs.Consumes({MediaType.APPLICATION_JSON, "text/json"})
@javax.ws.rs.Produces({MediaType.APPLICATION_JSON, "text/json"})
public class JacksonConfigurator extends JacksonJsonProvider {
private static final Logger log = Logger.getLogger(JacksonConfigurator.class.getName());
public JacksonConfigurator() {
super();
log.info("Configuring JSON data field mapping to C-style");
ObjectMapper mapper = _mapperConfig.getConfiguredMapper();
if (mapper == null) {
mapper = _mapperConfig.getDefaultMapper();
}
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
}