我正在使用spring框架开发restapi。我设置了一个后控制器:
@PostMapping(path="/v2/document", consumes= {"application/xml","application/json"}, produces={"application/xml","application/json"})
@ResponseBody
public ResponseEntity<Object> postDocument(HttpServletRequest request,@RequestBody Template template) throws Exception
它接受一个模板对象:公共类模板{
@XmlElement(name = "Callback")
private String Callback;
@XmlElement(name = "OutputFormat")
private String OutputFormat;
@XmlElement(name = "Data")
private byte[] Data;
@XmlElement(name = "ConnectionString")
private String ConnectionString;
@XmlElement(name = "Format")
private String Format;
@XmlElementWrapper(name="Properties")
@XmlElement(name = "Property")
private Property[] Properties;
现在这是一个有效的请求主体:
<Template>
<connectionString>ConString</connectionString>
<outputFormat>pdf</outputFormat>
<datasources>
<datasource>
<connectionString>ConString</connectionString>
</datasource>
</datasources>
</Template>
其中,外部标记是正确的pascalcase格式,但内部标记必须是camelcase格式。这就是我想让身体看起来的样子:
<Template>
<ConnectionString>ConString</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<ConnectionString>ConString</ConnectionString>
</Datasource>
</Datasources>
</Template>
1条答案
按热度按时间yhuiod9q1#
我要做的就是加上:
现在它按我想要的方式工作。