@RequestMapping(method=RequestMethod.POST, value="/employeeXML")
public ModelAndView addEmployeePostXMl(@RequestBody String body) {
Source source = new StreamSource(new StringReader(body));
Employee e = (Employee) jaxb2Mashaller.unmarshal(source);
employeeDS.add(e);
List<Employee> employees = employeeDS.getAll();
EmployeeList list = new EmployeeList(employees);
return new ModelAndView(XML_VIEW_NAME, "employees", list);
}
我可以为单个 POST 正文测试它,即
<employee>
<id>3</id>
<name>guest3</name>
<email>guest3@ibm.com</email>
</employee>.
但是如何检查它是否有多个 DYNAMIC 值,例如 CSV 文件。如果我使用带有数据的 csv 文件:
3 aFFaFD xfchghcxh
4 dsfgsdF cxhchcxht
5 asFDdsF chcxhcg
6 sdFsF cxhxhcgh
7 SDFsF cghcxhcg
8 gfzsgzd cxghchc
9 hgfxhfx cghchgc
10 fghxf ghcxhxc
11 fhgfxh cghchcc
12 ghcxxh cxhcghch
13 chgxgcvx cghchcxgch
14 hgxfhxch cxhgxchcg
15 ghcxhcx vmcvmnvbm
16 cghch bnmvmbh
17 cxghcxhcx mvbhgn
18 cxghcxh mnmcghmh
19 cxghcxhxch mnvmvmcv
20 xcghchcx mvcmvmv
它给出了解组异常,因为帖子正文应该是 XML 格式。