我希望能够直接从浏览器调用我的网络服务。通过 Web 浏览器从 HTTPClient 调用它是可以的,但是如果我尝试通过浏览器直接调用它,我会收到以下错误:
SEVERE: [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Could not instantiate JAXBContext for class [class com.mycompanay.MyClass]: 8 counts of IllegalAnnotationExceptions; nested exception is com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 8 counts of IllegalAnnotationExceptions
com.mycompany.MyInterface is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
com.mycompany.myInteface
at private java.util.List com.mycompanay.MyClass.values
at com.mycompanay.myClass
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
我试图通过 @XMLElement 注释引用实现类,但我得到了同样的错误:
public MyClass {
@XmlElement(type=MyInterfaceImpl.class, name="values")
private List<MyInterface> values;
@XmlElement(type=MyInterfaceImpl.class, name="values")
public void getValues() {
return values;
}
}