HTTP Url Connection Est。但不是开放

时间:2014-12-08 10:28:18

标签: java http jsf url httpconnection

我已经建立了与URL的连接。

使用此代码:

public void ExecURL()
{
    try {
        URL myURL = new URL("http://helpdesk.wi-tribe.net.pk:8080/secure/CreateIssueDetails!init.jspa?pid="+projID+"&issuetype="+issueID+"&"+customerField+"="+searchID+"&customfield_10014="+searchMAC+"&customfield_10016="+custMobile+"&reporter="+emailID);
        URLConnection myURLConnection = myURL.openConnection();
        myURLConnection.connect();
        System.out.println("connection est: " + myURL.toString() );
    } 
    catch (MalformedURLException e) { 
        // new URL() failed
        // ...
    } catch (IOException e) {   
        // openConnection() failed
        // ...
    }
}

我通过此<p:commandLink>

呼叫此连接
<p:commandLink update="@this"
               action = "#{visitBean.ExecURL}" 
               target = "_blank"
               value="Redirect To JIRA"
               process="@this,CustMob,CustID,MacAddr,EmailID"/>

现在,我知道已建立连接,但我的目标是使用<p:commandLink>在新窗口(Mozilla或Chrome)中打开此网址。

1 个答案:

答案 0 :(得分:0)

无论动作方法返回StringcommandLink标记都将用作导航目标。如果action方法返回null或void,则将重新加载当前页面。

因此,为了让JSF转到ExecURL()中构建的URL,您需要返回它。代码必须是这样的:

public String ExecURL() {
    return "http://helpdesk.wi-tribe.net.pk:8080/secure/CreateIssueDetails!init.jspa?pid=" + projID + "&issuetype=" + issueID + "&" + customerField + "=" + searchID + "&customfield_10014=" + searchMAC + "&customfield_10016=" + custMobile + "&reporter=" + emailID;
}