struts2.32 action通过httpclient调用自身

awusoft 2025-09-20 16:40:27

在某个Action的方法里,通过httpclient再访问自己这个方法,直接被卡住了,不知道要怎么解决这个问题,谢谢.

 

public void test() {
        Integer currNumber=getInt("a");
        if(currNumber==5){
            try {
                System.out.println("第5个请求,等等再返回");
                Thread.sleep(60000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            outSuccess();
            return;
        }
        System.out.println("获取参数:"+currNumber);
        GetMethod get= new GetMethod("http://localhost:8081/p-client/user!test.action?a="+(currNumber+1));
        get.addRequestHeader("Content-Type","application/json");
        HttpClient client=new HttpClient();
        try {
            System.out.println("为什么呀:"+currNumber);
            int code=client.executeMethod(get);
            System.out.println("当前:"+currNumber+"下家返回:"+code);
            String body=get.getResponseBodyAsString();
            get.releaseConnection();
            
        } catch (HttpException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

...全文
364 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

70,029

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧