Getting error A message body writer for Java class java.util.ArrayList/List was not found

前端 未结 1 1758
情书的邮戳
情书的邮戳 2020-12-07 06:07

well this has been posted a lot of time here but no solution worked for me...
i can avoid this error by making a wrapper class but it only returned

相关标签:
1条回答
  • You should add at least a getter in your StringWrapper. Without public attributes, there is nothing to serialize. So the output is correct. If you do not want a tag around the list of your strings, you can mark a single getter with @XmlValue.

    @XmlRootElement
    public class StringWrapper {
        public StringWrapper (){}
    
        List<String> list=new ArrayList<String>();
    
        public void add(String s) { list.add(s); }
    
        @XmlValue    
        public List<String> getData() { return list; }
    
    }
    
    0 讨论(0)
提交回复
热议问题