【问题标题】:How can blueimp communicate with a Java REST service, if possible如果可能,blueimp 如何与 Java REST 服务通信
【发布时间】:2023-03-27 21:31:01
【问题描述】:
$scope.$on('fileuploadadd', function(e,data) {

$http({ 
       method: 'POST',

            }).success().error();
}

我知道为单个简单文件上传编写上面的代码,但是使用 blueimp, 我可以管理我的休息服务的进度吗?上面的方法也是正确的吗? 我知道有一个data.submit 函数,但我不知道它怎么知道调用哪个服务器端操作。

【问题讨论】:

    标签: angularjs jquery-file-upload blueimp


    【解决方案1】:

    您可以根据 Javax RS Api 使用注解将请求方法映射到 restful 函数。所以这取决于你使用的是哪种 Restful Java Api。

    来自the oracle documentation的例子:

    package com.sun.jersey.samples.helloworld.resources;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Produces;
    import javax.ws.rs.Path;
    
    // The Java class will be hosted at the URI path "/helloworld"
    @Path("/helloworld")
    public class HelloWorldResource {
    
        // The Java method will process HTTP POST requests
        @POST
        // The Java method will produce content identified by the MIME Media
        // type "text/plain"
        @Produces("text/plain")
        public String getClichedMessage() {
            // Return some cliched textual content
            return "Hello World";
        }
    }
    

    Javascript:

     $('#fileupload').fileupload({
        url: 'http://yourSite/helloworld',
        type: 'POST',
        ...
    

    【讨论】:

    • 我的服务已经准备好了,问题是,我如何在 blueimp 事件中调用我的服务
    • @mervellous 我已经编辑了我的帖子,你只需要根据你的 REST 控制器添加你的 URL 和方法类型。
    • 插件似乎不支持删除和获取方法:github.com/blueimp/jQuery-File-Upload/wiki/Options#type
    猜你喜欢
    • 1970-01-01
    • 2013-08-20
    • 2011-05-25
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 2022-06-12
    • 1970-01-01
    相关资源
    最近更新 更多