2016-03-15 46 views
0

我有这样的HTTP标头的HTTP标头:添加参数使用Java Web服务

HTTP/1.1 200 OK 
    Server: Apache-Coyote/1.1 
    Content-Type: application/json;charset=UTF-8 
    Transfer-Encoding: chunked 
    Date: Tue, 15 Mar 2016 17:08:29 GMT 

,我想的是加入2参数:mytotalcount和mytotalresult。

我必须添加到我的反应然而,这是不工作我不能这样做:

response.Headers.Add("mytotalcount", "10"); 

也做不到

request.setAttribute("mytotalcount","10"); 

所以我阻止任何想法吗?谢谢你的帮助 !

下面是部分代码:

public class SitesResponse { 
private Result result; 
private List<GeographicSite> site; 
public SitesResponse() { 
    this.result = new Result(); 
    this.site = new ArrayList<GeographicSite>(); 
    } 
public List<GeographicSite> getSite() { 
    return site; 
} 
public void setSite(List<GeographicSite> site) { 
this.site = site; 
} 

} 套房L'AUTRE CLASSE魁利用SitesResponse

SitesResponse response = new SitesResponse(); 

if (testiing) { 
    try {response = siteManager.geographicSitesAPIV1(args); 
    response.getResult().setCode("error"); 
    response.getResult().setLabel("no addr found"); 

而这正是我试图...早些时候

System.out.println(response.toString().getBytes().toString()+"azezae"); 
    // request.Headers.Add("headername", "headervalue"); 
    // request.setAttribute("X-Total-Count","10"); 
    //response.setAttribute("X-Result-Count", "7"); 
    //response.setIntHeader("mytotalcount", 5); 
    //////////////////////////////////////////////////::::::: 

在图片在这里我想补充我的两个参数result from SOAPui

+0

“它不工作”发生了什么?你有错误吗? – 2016-03-15 17:47:41

+0

好吧,它不工作,我得到一个红线!无论是删除,重命名,或创建一个方法setAttribute !!!!! – Hopeful

回答

0

你好再次感谢您的时间, 我试图编辑的错误类,所以我做了什么,你只是

resp.addIntHeader(att, 10); 
    resp.addIntHeader(att2, 5); 

谢谢你的时间和答案!