在我的 Spring 应用程序中,我使用 Spring 4.0.4 和 Spring Security 3.2.3。我直接从 sprin 网站上的教程复制了此代码,但编译时遇到问题,因为registerAuthentication
无法从 WebSecurityConfigurerAdapter
类中覆盖该方法,并且该类HttpSecurity
没有 methode authorizeUrls
。我缺少一个罐子吗?或者说是版本问题?
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("letsnosh").password("noshing").roles("USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeUrls()
.antMatchers("/order/**").hasRole("USER")
.antMatchers("/checkout").hasRole("USER")
.anyRequest().anonymous()
.and()
//This will generate a login form if none is …
Run Code Online (Sandbox Code Playgroud) 我似乎无法在IntelliJ GUI构建器上运行表单
Exception in thread "main" java.awt.IllegalComponentStateException: contentPane cannot be set to null.
Run Code Online (Sandbox Code Playgroud)
我假设自动生成初始化视图的代码.现在我只有一个JPanel
并且不知何故它没有自动初始化,即使它在设计师身上清晰可见.
这是一个Gradle项目,我选择使用生成的main函数运行.
我需要做些什么才能让它发挥作用?
public class MyForm {
private JPanel jPanel;
public static void main(String[] args) {
JFrame frame = new JFrame("MyForm");
frame.setContentPane(new MyForm().jPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud) 我在 android 自定义文本视图中设置了多个标志属性,如何使用 TypedArray 恢复属性
<some.text.view.that.i.defined.TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
font:sanFrancisco="bold|italic"/>
<attr name="fontSanFrancisco">
<flag name="regular" value="0"/>
<flag name="bold" value="1"/>
<flag name="italic" value="2"/>
</attr>
<declare-styleable name="font">
<attr name="sanFrancisco" format="flag"/>
</declare-styleable>
Run Code Online (Sandbox Code Playgroud) 我正在管理用户可以喜欢的社交网络数据库,评论并为帖子创建了一个表格,例如和评论.
like --- post_id
user_id
comment --- post_id
user_id
Run Code Online (Sandbox Code Playgroud)
现在,当我运行时select * from post
,我希望能够添加两列,likes
并comments
计算每个列的喜欢和评论的数量post_id
.
我怎样才能做到这一点?
它应该匹配,"abababab"
因为"ab"
连续重复两次以上,但代码没有打印任何输出。在 C++ 中使用正则表达式还有其他技巧吗?
我尝试了其他语言,效果很好。
#include<bits/stdc++.h>
int main(){
std::string s ("xaxababababaxax");
std::smatch m;
std::regex e ("(.+)\1\1+");
while (std::regex_search (s,m,e)) {
for (auto x:m) std::cout << x << " ";
std::cout << std::endl;
s = m.suffix().str();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我已经尝试了各种方法,包括按照这篇文章的建议为CakePHP控制器单元测试设置标题设置标题,但我似乎无法在我的控制器单元测试中同意ajax请求.
我有这种情况
if ($this->request->is('ajax')) {
Run Code Online (Sandbox Code Playgroud)
还有这个
if ($this->params['isAjax'] == 1) {
Run Code Online (Sandbox Code Playgroud)
但是条件不满意.我甚至尝试设置数组值$this->params['isAjax'] = 1;
但是我得到了一个错误
Indirect modification of overloaded property RoomController::$params has no effect
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在cakePHP中对控制器进行单元测试时如何成功模拟ajax请求.
我'使用bash 4.3,我无法导出或设置docker-machine环境变量
bash-4.3$ docker-machine env default
set -gx DOCKER_TLS_VERIFY "1";
set -gx DOCKER_HOST "tcp://192.168.99.100:2376";
set -gx DOCKER_CERT_PATH "/Users/ofolorunso/.docker/machine/machines/default";
set -gx DOCKER_MACHINE_NAME "default";
# Run this command to configure your shell:
# eval (docker-machine env default)
Run Code Online (Sandbox Code Playgroud)
显然bash不承认g
旗帜
bash-4.3$ eval "$(docker-machine env default)"
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] …
Run Code Online (Sandbox Code Playgroud) 我有一个在main中声明的二维指针数组
char* data[3][8]
Run Code Online (Sandbox Code Playgroud)
我把它传递给了一个函数
void func(char*** data)
Run Code Online (Sandbox Code Playgroud)
当我printf("%p\n", data[0]);
在main
函数中和函数中执行时,我0x7ffeabc27640
在main和函数中得到了不同的输出(nil)
.虽然打印只data
输出与内部相同的地址main
.为什么我不能在函数中访问数组.