【问题标题】:Spring MVC XML viewSpring MVC XML 视图
【发布时间】:2013-12-18 13:18:03
【问题描述】:

我一直在关注一个教程here

就目前而言,它工作正常。

但如果我尝试将类层次结构转换为 XML,则会出现异常

例子:

@XmlRootElement(name = "stuff")
public class Stuff {

    @XmlMixed
    public List<Other> getList(){
      return records;
    }

}

其他类:

@XmlRootElement(name="other")
public class Other {
  @XmlAttribute int foo;
}

以及异常的重要部分:

class mypackage.Other nor any of its super class is known to this context.

【问题讨论】:

    标签: java xml spring spring-mvc


    【解决方案1】:

    这里有一个快速的解决方法:

    添加:

    @XmlSeeAlso(Other.class) to Stuff .
    

    您应该查看以下帖子以获得更多见解

    javax.xml.bind.JAXBException: Class *** nor any of its super class is known to this context

    JAXB Exception: Class not known to this context

    【讨论】:

      猜你喜欢
      • 2011-06-11
      • 2015-12-07
      • 2012-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多