小编use*_*019的帖子

Freemarker 模板中的 Keycloak 访问 cookie 和/或 url 查询参数

我想访问 keycloak freemarker 模板中的一些信息。我正在考虑两种方法。设置 url 参数并在 freemarker 模板中读取它们或将此信息设置为 cookie 并在模板中访问它们。

我已经尝试访问此处此处所述的 url 参数。但两者都不起作用。Keycloak 数据模型不为当前 Url 提供任何 getter。

其中一种方法可能吗?我怎样才能实现我的目标

freemarker keycloak

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

Angular 2 跨字段验证(基于模型)addErrors?

我正在对表单中的两个字段实施跨字段验证(基于反应/模型的方法),并且不知道应该如何将错误添加到表单控件的现有错误列表中

形式:

this.myForm = new FormGroup({
  name: new FormControl('', Validators.minLength(3));
  city: new FormGroup({
    cityOne: new FormControl('', Validators.minLength(3)),
    cityTwo: new FormControl('', Validators.minLength(3))
  }, this.validateEqualCities)
});
Run Code Online (Sandbox Code Playgroud)

验证器:

validateEqualCities(formGroup: FormGroup) {
    return (control: AbstractControl): { [key: string]: any } => {
    if (formGroup.controls['cityOne'].value &&  formGroup.controls['cityTwo'].value && formGroup.controls['cityOne'].value !== formGroup.controls['cityTwo'].value) {

     formGroup.controls['cityOne'].setErrors({ 'equalCities': true }, { emitEvent: true });
     formGroup.controls['cityTwo'].setErrors({ 'equalCities': true }, { emitEvent: true });

        return { 'equalCities': false };

    } else {
      formGroup.controls['cityOne'].updateValueAndValidity({ onlySelf: true, emitEvent: false });
      formGroup.controls['cityTwo'].updateValueAndValidity({ onlySelf: true, …
Run Code Online (Sandbox Code Playgroud)

forms validation form-control angular

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

Spring Autowire Bean具有多个接口实现,在方法中定义实现

我是春季和春季靴子的新手,所以希望这不是一个愚蠢的问题.

我有几个实现的接口.实现注释为@Component("NameOfImpl").

我的目标是使用选定的实现自动装配bean.在正常情况下我可以使用@Autowired @Qualifier("NameOfImpl"),但我的问题是我想在一个方法中选择一个实现,如:

public void doSomethingMethod(){ 
      for(String line: configFile){
                String[] values = line.split(";");

                if (values[0].equals("A")) {
                    //here I want to select an bean implementation

                }
                else if (values[0].equals("B")) {
                    //here I want to select another bean implementation

                }
      }
      bean.doSomething();
    }
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?你有什么建议?谢谢!

java spring spring-mvc autowired spring-boot

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

Angular2,相对导航(向后两级../../)

我的应用程序中有一个后退按钮,可以向后导航一些级别。如果是一级

this.router.navigate(['..'], { relativeTo: this.route });
Run Code Online (Sandbox Code Playgroud)

效果很好(生成的路由网址:)http://localhost:3000/three/two/one。在两级后退的情况下。导航

this.router.navigate(['..', '..'], { relativeTo: this.route });
Run Code Online (Sandbox Code Playgroud)

路由器向后导航两个级别,但生成的路由网址现在看起来像http://localhost:3000/three/two/(尾部斜杠,这是不正确的)。

我是在做错什么还是可能是错误?

navigation routing angular

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