使用子类对象执行Spring Rest Post时出错400

时间:2014-02-22 07:28:52

标签: java spring junit

我到了 从子类对象到超类引用执行Spring Rest Post时出错400

jUnit测试: - (失败)

SubClass subClassObj = new SubClass();
restTemplate.postForObject(restURL, subClassObj, SubClass.class);

弹簧控制器方法: -

@RequestMapping(method = RequestMethod.POST, value =
 "/post-subclass-obj", headers = "Accept=application/json") 

public @ResponseBody SuperClass postSubClassObj(@RequestBody SuperClass
 superClassObj) { 

        return superClassObj;
}

jUnit测试: - (工作正常)

SuperClass superClassObj = new SuperClass();
restTemplate.postForObject(restURL, superClassObj, SubClass.class);

先谢谢!!

0 个答案:

没有答案