【发布时间】:2014-12-26 23:36:06
【问题描述】:
在其余 Web 服务(例如 @Controller)中,我可以看到超过毫秒的时间,但在客户端通过 RestTemplate 使用其余 Web 服务时,第三个数字之外的每个字符都会丢失。例如,我可以看到 2014-12-22 09:52:35.371444 和 2014-12-22 09:52:34.00934 当我查看来自其余 Web 服务的返回(返回 testReturn)但我会看到 1419263555371 和 1419263554009 时我看客户端( _l )。我不是在询问格式(2014-12-22 09:52:35.371444 与 1419263555371)。我问的是在第一个示例中丢失 444,在第二个示例中丢失 34。请,如果有人用“objectMapper.enable(DeserializationFeature.etc)”指出一些解决方案,请告诉我如何设置它来影响 RestTemplate。我需要用“return testReturn”的完整时间戳填写“LogDisplay _l = restTemplate.postForObject”的返回。
//客户端
LogDisplay _l = restTemplate.postForObject(myServiceUrl,myPojoParameters, LogDisplay.class);
//与问题相关的pojo
import java.sql.Timestamp;
public class Lo_DisplayRecord {
String isParsable;
private Timestamp dateTime;
public Lo_DisplayRecord(String parseSw, Timestamp timeStamp){
super();
isParsable = parseSw;
dateTime = timeStamp; //the question is related to this variable
}
//包含其他pojo的pojo
@Component
public class LogDisplay {
public LogDisplay(){}
private ArrayList<Lo_DisplayRecord> displayValues; //pojo with the datetime variable
private int reportRowsLimit = 0;
private int reportRowsCount = 0;
public int getReportRowsLimit() {
return reportRowsLimit;
}
public ArrayList<Lo_DisplayRecord> getDisplayValues() {
return displayValues;
}
public void setDisplayValues(ArrayList displayValues) {
this.displayValues = displayValues;
}
}
//休息网络服务
@Autowired
private LogDisplay testReturn;
@RequestMapping(value="display/last", method=RequestMethod.POST)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public LogDisplay getLast(@RequestBody Mas60010 mas60010) {
try {
testReturn = lo_Mas60010.getLastDisplayValues(
return testReturn;
//mvc-dispatcher-servlet.xml
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonMessageConverter"/>
</list>
</property>
</bean>
<bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
</bean>
【问题讨论】:
标签: java spring rest jackson resttemplate