【问题标题】:how to send request get method in play framework如何在播放框架中发送请求获取方法
【发布时间】:2013-07-11 02:25:47
【问题描述】:

如何发送请求以获取方法?我有播放框架应用程序和 java 桌面应用程序。我想从 java 桌面发送一个请求以使用 get 方法播放框架。

这里是路由文件播放框架

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET     /                                 Application.index
POST    /auth                             Application.authenticator
POST    /datacompany                      Application.getDataCompany
POST    /listdatafile                     Application.getListFile
POST    /urlfile                          Application.getUrlFile
GET     /getFile/{id}                     Application.getFile
# Ignore favicon requests
GET     /favicon.ico                            404

# Map static resources from the /app/public folder to the /public path
GET     /public/                         staticDir:public

# Catch all                 
*/{controller}/{action}                  {controller}.{action}

这是应用程序控制器播放中的方法

  public static void getFile(String id){
   //String id = params.get("id");
        System.out.println("ID : "+id);
        FileInputStream stream = ResumableDownloader.getFile(id);
        renderBinary(stream);
    }

哦,我现在只想向GET /getFile/{id} Application.getFile发送请求

感谢和抱歉我的英语不好

【问题讨论】:

    标签: java playframework playframework-1.x


    【解决方案1】:

    您需要在 Java 桌面应用程序中使用 HTTP 客户端。查看 HttpClient:http://hc.apache.org/httpcomponents-client-ga/

    【讨论】:

    • 我曾尝试过该方法,当我使用该方法时,org.apache.commons.logging 显示 classNotFoundException 错误。我尝试将库 common-logging-1.1.3.jar 添加到我的项目中,但它不起作用。
    • 听起来你需要整理项目类路径
    猜你喜欢
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多