Struts2从服务器重定向到外部URL

时间:2019-09-26 19:19:45

标签: java servlets struts2 struts

我有一个应用程序,我试图将其重定向到外部URl(https),但是我的页面没有移动到新的URL。该应用程序正在浏览器中将URL作为GET请求触发。参见下面的代码;

动作类

public String Authorization() {

HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost();     

try {

    post.setHeader("Accept", "*/*");    
    post.setHeader("Allow-Origin", "*");
    post.setHeader("Cache-Control", "no-cache");
    post.setHeader("Accept-Encoding", "gzip, deflate");             
    post.setHeader("Connection", "keep-alive");
    post.setHeader("cache-control", "no-cache");
    post.setHeader("content-type", "text/xml,application/xml");

    jsonData.put("url", loginManager.Authorize());          
    HttpResponse response = client.execute(post);
    System.out.println("Response Code : " + response.getStatusLine().getStatusCode());


} catch (Exception e) {
    // TODO Auto-generated catch block
    logger.error(e.getMessage());
}
return Action.SUCCESS;

}

STRUTS.xml

<action name="AuthenticateO365" class="org.myapp.product.controller.LoginAction" method="Authorization">            
<result name="input"></result>
<result name="success" type="redirect">${jsonData.url}</result>  

0 个答案:

没有答案