我正在使用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]

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

  1. java hashtable put_Java Hashtable put()方法与示例

    哈希表类put()方法put()方法在java.util包中可用. put()方法用于将给定的键元素(key_ele)放入给定的值元素(val_ele). put()方法是一个非静态方法,只能通过类对 ...

  2. JAX-RS(Java API for RESTful Web Services)常用注解

    为什么80%的码农都做不了架构师?>>>    概述 JAX-RS(Java API for RESTful Web Services)是Java 提供用于开发RESTful Web ...

  3. jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档

    原文:https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS) Content Tuto ...

  4. 用 Java 技术创建 RESTful Web 服务--转载

    简介 JAX-RS (JSR-311) 是为 Java EE 环境下的 RESTful 服务能力提供的一种规范.它能提供对传统的基于 SOAP 的 Web 服务的一种可行替代. 在本文中,了解 JAX ...

  5. java官方 jax rs_jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档

    原文:https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS) Content Tuto ...

  6. java的set和get方法实例化_java反射机制 调用get set 方法 | 学步园

    调用get set 方法,需要 某一个类  类中的字段  字段的值来实现 代码: package entity; import java.lang.reflect.Method; import jav ...

  7. Java操作Elasticsearch的所有方法

    使用Java操作Elasticsearch的所有方法 13.1 Elasticsearch简介 Elasticsearch是基于Lucene开发的一个分布式全文检索框架,向Elasticsearch中 ...

  8. Spring MVC 控制层model.addAllAttribute()和model.addAllAttributes()方法的区别

    model.addAllAttributes(ladingInfoList); //model.addAllAttributes(map); model.addAttribute("tota ...

  9. 编写高质量代码:改善Java程序的151个建议 (第1章 Java开发中通用的方法和准则)

    第1章 Java开发中通用的方法和准则 The reasonable man adapts himself to the world;the unreasonable one persists in ...

最新文章

  1. jQuery插件开发 - 其实很简单
  2. Paddle中的自动微分功能测试
  3. Linux进程top命令作用是,Linux中top命令起什么作用呢?
  4. 图像降噪算法——图像噪声模型
  5. .net core项目实战之开发环境搭建
  6. matlab散点光滑连线,科研画图:散点连接并平滑(基于Matlab和Python)
  7. java 时间衰减函数_TensorFlow实现指数衰减学习率的方法
  8. linux备份mysql需要暂停服务吗_【MySQL运维】线上MySQL数据库停服迁移流程
  9. 工业级交换机的功率和管理功能详解
  10. 谷歌新玩具Vision Kit,带你DIY一个能识别千种物体的AI摄像头
  11. cas4.0 mysql_【SSO单点系列】:CAS4.0 CAS整合SpringMVC+MyBatis实现数据库校验(04)
  12. Xception: DeepLearning with Depthwise Separable Convolutions2017Google【论文理解】
  13. 解决在TP5中无法使用快递鸟的即时查询API
  14. 软件质量保障之代码走查
  15. 初步实现免费下载百度文库word文档(只限纯文本文档)----------------(浏览器控制台执行js代码)
  16. C++_SHFileOperation文件夹操作
  17. EI的检索方法快速检索(Quick Search)
  18. 量化基金股票的投资策略有哪些?
  19. source insight4.0使用教程
  20. 【软件工具】Anaconda使用总结

热门文章

  1. R语言实现EMD分析
  2. 和老外交流最常用1000句口语(前100句)
  3. 微信小程序之from表单提交数据到PHP后台
  4. IDEA无法连接远程代码仓库
  5. 一颗树,两棵树,三棵树_TREE_TO_Tree
  6. 视频人脸识别和图片人脸识别的关系
  7. (毕设)超声波测距仪—倒车雷达电路(原理图和PCB源文件
  8. 为什么你的时间总是不够用?
  9. 【CC3200AI 实验教程6】疯壳·AI语音人脸识别(会议记录仪/人脸打卡机)-串口
  10. MybatisPlus的增删改查以及特点