小编ran*_*er1的帖子

当数字等于 0 时,如何使用流跳过 limit(number) 调用?

我有一些 Java 代码从items. 它基于以下条件限制它们maxNumber

items.stream()
     .map(this::myMapper)
     .filter(item -> item != null)
     .limit(maxNumber)
     .collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)

它工作正常,但问题是:有没有办法跳过限制maxNumber == 0

我知道我可以这样做:

if (maxNumber == 0) {
    items.stream()
         .map(this::myMapper)
         .filter(item -> item != null)
         .collect(Collectors.toList());
} else {
    items.stream()
         .map(this::myMapper)
         .filter(item -> item != null)
         .limit(maxNumber)
         .collect(Collectors.toList());
}
Run Code Online (Sandbox Code Playgroud)

但也许有更好的方法,您有什么想法吗?

java java-8 java-stream

20
推荐指数
2
解决办法
667
查看次数

我怎样才能将我的ul li列表放在css中心?

我有以下HTML代码:

<section class="video">
            <div class="container">
                <div class="row">
                    <div class="col-md-12 text-center">

                        <ul class="footer-nav">
                            <li><a href="#">Contact</a></li>
                            <li><a href="#">Press</a></li>
                            <li><a href="#">Careers</a></li>
                            <li><a href="#">Business</a></li>
                            <li><a href="#">Careers</a></li>
                            <li><a href="#">Business</a></li>
                        </ul>

                    </div>
                </div>
            </div>
        </section>
Run Code Online (Sandbox Code Playgroud)

并且包含我的CSS(在jsfiddle中)我得到的结果是文本与左边对齐...我如何将所有内容都居中,所以结果如下:

                  Contact  Press  Careers  Business  Careers  Bussiness 
Run Code Online (Sandbox Code Playgroud)

?谢谢.

html css

11
推荐指数
1
解决办法
3万
查看次数

我在尝试访问Amazon Elastic Bean Stalk上的spring boot应用程序时收到错误404

我开发了一个spring boot应用程序,我将以下条目放入src/main/resources/application.properties:

spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
server.port=5000
Run Code Online (Sandbox Code Playgroud)

现在,当我mvn clean spring-boot:run在本地启动它()时,我正在获取输出,Tomcat started on port(s): 5000 (http)并且可以在浏览器的http:// localhost:5000/welcome下访问该应用程序.

Java在Amazon Elastic Bean Stalk中创建了一个实例,我上传了war,我甚至在EC2实例的相应安全组中打开了端口5000:

在此输入图像描述

但是当我现在去http://my-aws-ebs-instance.com/welcome:5000时,我收到以下消息:

在此输入图像描述

Whitelabel错误页面此应用程序没有/ error的显式映射,因此您将此视为回退.

Thu Dec 20 16:30:33 UTC 2018出现意外错误(type = Not Found,status = 404)./welcome.jsp

为什么哦为什么会这样发生?我忘了配置什么?

- - 编辑

根据要求,这是根java类:

package com.hellokoding.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(WebApplication.class); …
Run Code Online (Sandbox Code Playgroud)

war amazon-web-services spring-boot amazon-elastic-beanstalk

10
推荐指数
1
解决办法
662
查看次数

如何检查我的arraylist中是否有不在hashmap中的元素?

我有一个List<String>in java并且它包含一些字符串.

我也有一个hashmapString值,我想检查我的列表中是否有任何不在Hashmap中的元素.这是我写的代码:

List<String> someStrings = fetchData();
if (someStrings.stream().noneMatch(s -> myHashMap.containsValue(s))) {
    return false;
} 
return true;
Run Code Online (Sandbox Code Playgroud)

但它不能正常工作.你能帮帮我吗?

java collections java-8 java-stream

7
推荐指数
2
解决办法
522
查看次数

如何在Javascript中以格式hh:mm AM/PM获取当前时间?

我有一个Javascript,我需要以HH:MM AM/PM格式粘贴当前时间.有一个问题 - 我需要把时间从两个小时开始,所以例如,而不是晚上7:23,我需要把晚上9:23等等.

我尝试做类似的事情:var dateFormat = new Date("hh:mm a")但它没有用.我也试过用:

var today = new Date();
var time = today.toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3")
alert(time);
Run Code Online (Sandbox Code Playgroud)

但我所看到的只有18:23而不是下午6:23(可能是因为toLocaleTimeString()和我在欧洲的位置) - 也许有一些统一的方法可以在世界各地运作吗?另外,我不确切知道如何将2小时添加到最终结果中.你能帮助我吗?谢谢!

javascript datetime date datetime-format

6
推荐指数
2
解决办法
3万
查看次数

如何配置ffserver以支持rtmp而不是http?

我使用ffmpeg和以下命令从相机中获取图像:

ffmpeg -y -f vfwcap -r 25 -i 0 http://10.172.180.235:8090/feed2.ffm
Run Code Online (Sandbox Code Playgroud)

在其他机器上(使用上面提到的ip)我使用以下配置文件运行ffserver:

HttpPort 8090
HttpBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 3000
CustomLog -
<Stream stat.html>
    Format status
    ACL allow localhost
    ACL allow 192.168.0.0 192.168.255.255
    ACL allow 10.172.180.199
    ACL allow 10.172.180.216
    ACL allow 10.172.180.215
</Stream>
<Feed feed2.ffm>
    File /tmp/feed2.ffm
    FileMaxSize 1G 
    ACL allow 127.0.0.1
    ACL allow 10.172.180.199
    ACL allow 10.172.180.216
    ACL allow 10.172.180.236
    ACL allow 10.172.180.109
</Feed>
<Stream live.flv>
    Format flv
    Feed feed2.ffm

    VideoCodec libx264
    VideoFrameRate 30
    VideoBitRate 800
    VideoSize 1280x720 …
Run Code Online (Sandbox Code Playgroud)

ffmpeg rtmp video-streaming ffserver mediaelement.js

6
推荐指数
0
解决办法
3296
查看次数

我在ios应用中实施了谷歌登录.现在,我如何验证用户是否已登录,如果没有 - 使用Swift将其返回登录页面?

正如我在这个问题的标题中写的那样 - 我浏览了本教程https://developers.google.com/identity/sign-in/ios/sign-in,现在我可以将用户登录到我的应用程序了基于他的谷歌凭据.

到目前为止我的方式是我有一个ViewController.swift类,代码如下:

class ViewController: UIViewController, GIDSignInUIDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        let background = CAGradientLayer().greenBlue()
        background.frame = self.view.bounds
        self.view.layer.insertSublayer(background, atIndex: 0)
        //GIDSignIn.sharedInstance().uiDelegate = self

        // Uncomment to automatically sign in the user.
        //GIDSignIn.sharedInstance().signInSilently()

    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        GIDSignIn.sharedInstance().uiDelegate = self

        GIDSignIn.sharedInstance().signInSilently()
    }

    @IBAction func didTapSignOut(sender: AnyObject) {
        GIDSignIn.sharedInstance().signOut()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) { …
Run Code Online (Sandbox Code Playgroud)

ios swift google-signin

6
推荐指数
1
解决办法
7520
查看次数

如何在alamofire中快速打印来自post请求的响应的json内容?

好的,所以我正在使用alamofire,我传递的参数是有效的.这是迄今为止的代码:

Alamofire.request(.POST, "http://mywebservice.com", parameters: myparameters)
.response { (request, response, data, error) in
    if(error != nil){
        print("error= \(error)")
    }else{
        print("there was no error so far ")
        print(data)
        var json = JSON(data!)

        print(json) //prints unknown
        print(json["id"]) //prints null      
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的东西,但到目前为止没有任 我正在使用alamofire和swiftyjson,来自webservice的响应json是:

{
  "id": "432532gdsg",
  "username": "gsdgsdg"
}
Run Code Online (Sandbox Code Playgroud)

如果成功,我想分别打印两个值.我该怎么做?

ios swift alamofire swifty-json

6
推荐指数
1
解决办法
5853
查看次数

如何在引导程序中验证是否至少标记了一个复选框并将此信息传递给php?

我正在使用引导程序,并创建了具有8个复选框的表单。当用户单击“提交”时,我要验证是否至少标记了一个复选框,如果没有,请在复选框组下方显示一条错误消息,让用户知道。另外,我想用我的默认数据表格来验证他输入的日期是否正确:23/09/2015 05:45 PM

这是我的Java脚本验证代码:

$('#myform').validate({// initialize the plugin
    errorElement: 'div',
    rules: {
        datetimepicker: {
            required: true,
            date: true
        },
        commercialText: {
            required: true,
            minlength: 5
        },
        terms: {
            required: true,
            maxlength: 2
        }
    },
    submitHandler: function (form) { 
        var text = $("#customtext").val();
        var date = $("#datetimepicker").val();
        var stand = 2; 
        $.ajax({
            url: 'savedatanow.php',
            type: "POST",
            data: {
                text: text,
                date: date,
                stand: stand

            },
            dataType:'text',
            success: function(response)
            {

                alert(response);
            }
        });
        //alert('outside ajax');
    },
    highlight: function (element) {
        $(element).closest('.form-group').removeClass('success').addClass('has-error');
    }, …
Run Code Online (Sandbox Code Playgroud)

javascript php validation jquery twitter-bootstrap

5
推荐指数
2
解决办法
2万
查看次数

如何根据json应显示的日期和时间显示json收到的字符串元素?

我有一个数据库,我在那里存储一个文本,它的持续时间和它应该出现在网页上的时间.

php的结果如下:

{"text_content":"dgsgdsgds","text_duration":"15","start_time":"2015-09-28 23:11:15"},{"text_content":"dgsgdsgds","text_duration":"15","start_time":"2015-09-28 23:11:30"},{"text_content":"gdsgdsgds","text_duration":"15","start_time":"2015-10-01 14:00:00"}
Run Code Online (Sandbox Code Playgroud)

我有一个jquery脚本从数据库中提取数据并将其打印在屏幕上:

var results =[];
var cursor = 0;

function myFunction () {
    $.getJSON('list2.php', function(json) {
        results = json;
        cursor = 0;

        // Now start printing
        printNext();
    });
}

function printNext(){
    if(cursor == results.length){
        // Reset the cursor back to the beginning.
        cursor = 0;
    }

    // Print the key1 in the div.
    //$('#mydiv').html(results[cursor].key1);
    $('#mydiv').hide('fast', function(){ $('#mydiv').html(results[cursor].text_content); $('#mydiv').show('fast'); });

    // Set a delay for the current item to stay
    // Delay is key2 * 1000 …
Run Code Online (Sandbox Code Playgroud)

php jquery json

5
推荐指数
1
解决办法
60
查看次数