Spring MVC返回Snake案例

时间:2016-04-06 02:28:27

标签: java json spring spring-mvc

我遇到了困难,需要一些帮助。具体来说,我有一个像这样定义的POJO:

private String uid;
private String userName;
private String firstName;
private String lastName;

我的DAO看起来像:

@Override
public AAAUserCountDTO getUserCount(final String userName, final Date startDate, final Date endDate)
        throws BadParameterException {
    final String sql = "select uid, user_name, first_name, last_name from usage where user_name = :user_name and process_time >= :start_date and process_time < :end_date";

    final SqlParameterSource namedParameters = new MapSqlParameterSource().addValue("user_name", userName)
            .addValue("start_date", startDate).addValue("end_date", endDate);

    try {
        return jdbcTemplate.queryForObject(sql, namedParameters,
                new BeanPropertyRowMapper<DTO>(DTO.class).se);

    } catch (EmptyResultDataAccessException e) {
        throw new BadParameterException();
    }
}

我的应用程序yml文件中也有这个设置:

spring:
   application:
      name: Usage Service
   jackson:
      property-naming-strategy: CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES

我的回答如下:

uid: 1234,
userName: "Bob",
firstName: "Bob",
lastName: "Hopkins",
etc...

如何在不必将JSON属性表示法中的每个表示为POJO的一部分的情况下强制执行

由于

0 个答案:

没有答案