小编Vai*_*hav的帖子

$ elemMatch相当于spring数据mongodb

我需要知道spring数据mongo db中的等效代码到下面的代码: -

db.inventory.find( {
                     qty: { $all: [
                                    { "$elemMatch" : { size: "M", num: { $gt: 50} } },
                                    { "$elemMatch" : { num : 100, color: "green" } }
                                  ] }
                   } )
Run Code Online (Sandbox Code Playgroud)

mongodb spring-data-mongodb

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

使用Spring Security时,允许所有域使用iframe

我正在使用Spring Security。默认情况下,它不允许在iframe中加载页面。

Spring Security设置标头X-Frame-Options'DENY'。我不希望此标头包含在我的应用程序中。

这是我的配置文件。

package com.some.package.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import com.some.package.crm.enums.Role;
import com.some.package.security.AuthSuccessHandler;
import com.some.package.security.AuthenticationProvider;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private AuthenticationProvider authenticationProvider;

    @Autowired
    private AuthSuccessHandler authSuccessHandler;

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider);

    }
    @Bean
    public PasswordEncoder getPasswordEncoder(){
        PasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder;
    }

    @Override
    public void …
Run Code Online (Sandbox Code Playgroud)

iframe spring spring-mvc spring-security x-frame-options

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

单击 iframe,在浏览器中打开新选项卡

我想在单击 iframe 窗口中的任意位置时打开新选项卡。

<div id="iframeDiv">            
    <iframe id="frame" src="anysite.com" width="100%" height="400"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)

单击 iframeDiv 时,我想在新的浏览器选项卡中打开 anysite.com

html iframe

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

为什么HashSet调用compareTo方法并导致NullPointerException

我在增加值HashSet和获取NullPointerExceptioncompareTo方法.

java.lang.NullPointerException
    at com.fiveIQ.document.Link.compareTo(Link.java:226)
    at com.fiveIQ.document.Link.compareTo(Link.java:16)
    at java.util.HashMap.compareComparables(HashMap.java:371)
    at java.util.HashMap$TreeNode.treeify(HashMap.java:1920)
    at java.util.HashMap.treeifyBin(HashMap.java:771)
    at java.util.HashMap.putVal(HashMap.java:643)
    at java.util.HashMap.put(HashMap.java:611)
    at java.util.HashSet.add(HashSet.java:219)
    at com.fiveIQ.crawlData.parser.EightyLegJsonParser.parse(EightyLegJsonParser.java:51)
    at com.fiveIQ.crawlData.processor.CrawlDataParser.process(CrawlDataParser.java:57)
    at com.fiveIQ.crawlData.processor.CrawlDataUploader.upload(CrawlDataUploader.java:31)
    at com.fiveIQ.crawlData.processor.CrawlDataUploaderExecutor$1.run(CrawlDataUploaderExecutor.java:85)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)

这是我的compareTo方法.的价值updatedOn是零.但我不明白为什么HashSet要打电话compareTo

@Override
public int compareTo(Link o)
{
    return o.updatedOn.compareTo(this.getUpdatedOn());
}
Run Code Online (Sandbox Code Playgroud)

java collections

2
推荐指数
1
解决办法
872
查看次数