创建新的 MappingJacksonHttpMessageConverter 时,我的代码挂起。我在 Android 4.1.2 上运行。代码如下
public void login(String empCode, String password) {
RestTemplate rt = new RestTemplate();
MappingJacksonHttpMessageConverter jackson = new MappingJacksonHttpMessageConverter();
try{
rt.getMessageConverters().add(jackson);
rt.getMessageConverters().add(new StringHttpMessageConverter());
} catch(Exception ex) {
ex.printStackTrace();
}
String uri = new String("http://43.68.85.137:8080/cimweb/api/authenticateEmployee");
Employee employee = new Employee();
employee.setEmpCode(empCode);
employee.setPassword(password);
employee.setAuthenticUser(false);
Employee returns = rt.postForObject(uri, employee, Employee.class);}
这是日志
08-14 16:11:41.250: E/dalvikvm(15517): 找不到类 'org.codehaus.jackson.map.ObjectMapper',引用自方法 org.springframework.http.converter.json.MappingJacksonHttpMessageConverter。08-14 16:11:41.250: W/dalvikvm(15517): VFY: 无法解析 Lorg/springframework/http/converter/json/MappingJacksonHttpMessageConverter 中的新实例 807 (Lorg/codehaus/jackson/map/ObjectMapper;);08-14 16:11:41.250: D/dalvikvm(15517): VFY: 在 0x000e 处替换操作码 0x22