2012-04-10 3 views
2

resteasy api xml 및 json 출력에 대한 링크를 추가해야합니다.HATEOAS 링크를 클릭 할 수 있습니까?

package samples; 
import javax.xml.bind.annotation.XmlAttribute; 
import javax.xml.bind.annotation.XmlRootElement; 

@XmlRootElement(name="link", namespace="http://www.w3.org/2005/Atom") 

public class AtomLink { 
    private String rel; 
    private String href; 
    private String type; 

    public AtomLink() {} 

    public AtomLink(String rel, String href, String type) { 
     this.rel = rel; 
     this.href = href; 
     this.type = type; 
    } 

    public AtomLink(String rel, String href) { 
     this(rel,href,"application/xml"); 
    } 

    @XmlAttribute 
    public String getRel() { 
     return rel; 
    } 
    public void setRel(String rel) { 
     this.rel = rel; 
    } 

    @XmlAttribute 
    public String getHref() { 
     return href; 
    } 
    public void setHref(String href) { 
     this.href = href; 
    } 

    @XmlAttribute 
    public String getType() { 
     return type; 
    } 
    public void setType(String type) { 
     this.type = type; 
    } 

} 

을 다음과 내 JAXB의 XML 또는 JSON 개체의 링크 값을 설정 한 그래서 나는 JAXB AtomLink 클래스를 썼다. 출력은 다음과 같습니다. 그러나 링크는 클릭 할 수 없습니다.

출력 :

<data xmlns:ns2="http://www.w3.org/2005/Atom"> 
<bucket id="2" name="2012-APR-09 12:05 AM"> 
<av_data unit="percent" value="100"/> 
<data_count unit="#" value="10"/> 
<pf_data unit="seconds" value="4.618"/> 
</bucket> 
<ns2:link href="http://localhost:8080/webapp/api/getrawdata?start=3&size=2" rel="next" type="application/xml"/> 
</data> 

내가 링크를 클릭 할 수 있도록하려면 어떻게해야합니까.

미리 감사드립니다. Anitha

답변

2

XML 및 JSON은 텍스트 기반의 데이터 표현입니다. 링크를 클릭하는 기능은 해당 텍스트의 일부를 링크로 인식하여 하이퍼 링크로 렌더링하는 데이터 기능을 보는 데 사용하는 브라우저에 따라 다릅니다.

+0

답장을 보내 주셔서 감사 드리며 의심의 여지가 없어졌습니다. – Anitha

관련 문제