我想有以下返回給瀏覽器(查看源代碼)莫西的@XmlCDATA似乎也沒有影響
<content>
<![CDATA[Please show this inside a unescaped CDATA tag]]>
</content>
但我實際上可以得到
<content>
Please show this inside a unescaped CDATA tag
</content>
如果我改變的價值內容爲
& lt;![CDATA [請在未轉義的CDATA標籤中顯示此內容]] & gt; ,標籤的小於和大於轉義。想知道如何實現我想要的嗎???? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
這裏是我的代碼
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/myRequest")
public class MyRestClass {
@GET
@Path("{myPathNumber}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Object doInquiry(@PathParam("myPathNumber") String myPathNumber) {
try {
return new MyObject();
} catch (Exception e) {
return "exception " + e.getMessage();
}
}
}
package org.openengine.wink;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.oxm.annotations.XmlCDATA;
@XmlRootElement
public class MyObject implements Serializable {
@XmlElement
@XmlCDATA
private String content = "Please show this inside a unescaped CDATA tag";
}
在包org.openengine.wink
我有一個文件,jaxb.properties
,具有以下內容
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory