小编Bat*_*azi的帖子

从 jsonb 数组中删除元素

我有以下jsonb。我想从数组页面中删除名为“pageb”的元素。类似问题中提供的解决方案对我不起作用。

'{
  "data": {
    "id": "a1aldjfg3f",
    "pages": [
      {
        "type": "pagea"
      },
      {
        "type": "pageb"
      }                                
    ],
    "activity": "test"
  }
}'
Run Code Online (Sandbox Code Playgroud)

我的脚本现在看起来像这样。它不会返回任何错误,但不会删除元素。

  UPDATE database
  SET reports = jsonb_set(reports, '{data,pages}', (reports->'data'->'pages') - ('{"type":"pageb"}'), true)
  WHERE reports->'data'->'pages'  @> '[{"type":"pageb"}]';
Run Code Online (Sandbox Code Playgroud)

postgresql jsonb

4
推荐指数
2
解决办法
4526
查看次数

使用Spring Security从静态文件夹服务Angular 2项目

因此,我在Angular2上有一个工作的前端,在Java上有一个工作的后端,我要做的是从静态文件夹中提供index.html,该文件夹还包含我所有的前端资源。问题是,当我尝试将Spring Security添加到后端时,由于@EnableWebSecurity批注,资源不再可访问。当我导航到本地主机http:// localhost:8080 /时,index.html不被提供。但是,如果我访问它或任何其他手动编写路径的资源,它将加载。我不想为前端服务有所不同,有什么办法可以从静态方式做到这一点?我尝试了以下方法:

这里是我的安全配置:

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@ComponentScan(basePackages = {"com.ramso.restapi.security"})
public class SecurityConfig extends WebSecurityConfigurerAdapter {

private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);

public static final String REMEMBER_ME_KEY = "rememberme_key";

public SecurityConfig() {
    super();
    logger.info("loading SecurityConfig ................................................ ");
}

@Autowired
private UserDetailsService userDetailsService;

@Autowired
private RestUnauthorizedEntryPoint restAuthenticationEntryPoint;


@Autowired
private AuthenticationSuccessHandler restAuthenticationSuccessHandler;

@Autowired
private AuthenticationFailureHandler restAuthenticationFailureHandler;

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


@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/front/**","/index.html");
} …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-security angular

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