
[英]How to POST a JSON payload to a @RequestParam in Spring MVC
[英]Json payload is empty while xml is working fine for Spring MVC project
我正在使用 Spring MVC 项目。 XML 有效负载工作正常,但 JSON 有效负载为空。 为什么 json 有效负载为空的任何帮助。 WEB-INF 中的罐子是:
dispatcher_servlet.xml 也添加了 messageConvertor:
<mvc:annotation-driven>
<mvc:message-converters>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper" ref="jacksonMapper" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<context:annotation-config /><bean id="jacksonMapper"
class="com.ingrian.webservices.aws.rest.controller.CustomObjectMapper" />
CustomObjectMapper 类如下:
public class CustomObjectMapper extends ObjectMapper {
public CustomObjectMapper() {
super();
super.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
super.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = AnnotationIntrospector.pair(primary,
secondary);
super.setAnnotationIntrospector(pair);
}
}
早些时候,它在给定 jar 的旧版本上运行良好。 当我更新它们时,它不起作用。 代码似乎没有问题,但 Jars 似乎没有问题。 有什么不见了? 有什么帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.