java model.put_java-Restful PUT方法的ModelAttribute未填充值(JSO...

我正在使用Spring MVC构建一个完全宁静的Web应用程序.当我有一个PUT方法时,不会填充我的@ModelAttribute表单bean(所有值都为null).如果我使用POST方法,则所有内容都会正确填充.

@Entity

@Table(name = "positiongps")

public class PositionGPS implements BaseEntity {

private static final long serialVersionUID = 1L;

@Id

@GeneratedValue(strategy = GenerationType.AUTO)

@Column(name = "id", nullable = false, columnDefinition = "SERIAL", updatable = false)

private Long id;

@Column(name = "latitude", precision = 11, scale = 7, columnDefinition = "NUMERIC", nullable = false, updatable = true, unique = false)

private BigDecimal latitude;

@Column(name = "longitude", precision = 11, scale = 7, columnDefinition = "NUMERIC", nullable = false, updatable = true, unique = false)

private BigDecimal longitude;

// ** Constructeur **//

public PositionGPS() {

super();

latitude = new BigDecimal("0");

longitude = new BigDecimal("0");

}

// ** Get and Set **//

.

@ResponseBody

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)

public boolean update(@ModelAttribute("positionGPS") PositionGPS positionGPS, @PathVariable Long id, Model model) {

LOG.debug("update :: IN, PositionGPS.Id=[" + id + "]");

PositionGPS positionGPSOld = positionGPSService.getById(id);

LOG.debug("update :: getId=[" + positionGPS.getId() + "]");

LOG.debug("update :: getLatitude=[" + positionGPS.getLatitude() + "]");

LOG.debug("update :: getLongitude=[" + positionGPS.getLongitude() + "]");

try {

if (positionGPSOld != null) {

positionGPSOld.setLatitude(positionGPS.getLatitude());

positionGPSOld.setLongitude(positionGPS.getLongitude());

PositionGPS newpositionGPS = positionGPSService.update(positionGPSOld);

} else {

LOG.debug("update :: PositionGPS Error test");

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return true;

}

web.xml中

springSecurityFilterChain

org.springframework.web.filter.DelegatingFilterProxy

springSecurityFilterChain

/*

httpMethodFilter

org.springframework.web.filter.HiddenHttpMethodFilter

httpMethodFilter

/*

我的控制台:

DEBUG: PositionGPSController - update :: IN, PositionGPS.Id=[136]

DEBUG: PositionGPSController - update :: getId=[136]

DEBUG: PositionGPSController - update :: getLatitude=[0]

DEBUG: PositionGPSController - update :: getLongitude=[0]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值