小编bie*_*las的帖子

将验证器添加到响应式表单时出错

我创建了一个简单的表单,我想向其中添加一个验证器:

 form;

  constructor() { 
    this.form = new FormGroup({
    'old-password' : new FormControl('', [Validators.required, Validators.minLength(4)], PasswordValidators.checkPassword),
    'new-password' : new FormControl('', [Validators.required, Validators.minLength(4)]),
    'confirm-password' : new FormControl('', [Validators.required, Validators.minLength(4)])
  }, {
      validator: PasswordValidators.passwordsShouldMatch
    });
  }
Run Code Online (Sandbox Code Playgroud)

但在validator部分我收到一个错误,它说:

[ts]
Argument of type '{ validator: (control: AbstractControl) => { passwordsShouldMatch: boolean; }; }' is not assignable to parameter of type 'ValidatorFn'.
  Object literal may only specify known properties, and 'validator' does not exist in type 'ValidatorFn'.
(property) validator: (control: AbstractControl) => {
    passwordsShouldMatch: …
Run Code Online (Sandbox Code Playgroud)

validation typescript angular

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

尝试运行 npm run build 时出错

我用Spring Boot和创建了一个简单的应用程序Angular 4。我试图运行一个脚本,它将把每个 ( npm run build) 文件从前端文件打包到src/main/resources/static文件中。但我收到一个错误,即:

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! tasks@0.0.0 postbuild: `npm run deploy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tasks@0.0.0 postbuild script 'npm run deploy'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm …
Run Code Online (Sandbox Code Playgroud)

spring package spring-boot angular

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

每当宣布停止请求时,HasAnyAuthority 总是让我进入 api

通过 Spring Security 我创建了一个方法:

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired
    private UserDetailsService userDetailsService;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
            .csrf().disable()
            .authorizeRequests()
                .antMatchers("/static/build/app.js", "/static/app/styles/*/**", "/static/app/js/*/**",
                        "/static/build/libs.js", "/index.html", "/static/build/*/**", "/", "/static/**").permitAll()
                .antMatchers("/auth/**").permitAll()
                .antMatchers("/api/user/registerClient").permitAll()
                .antMatchers("/api/user/checklogin/**").permitAll()
                .antMatchers("/api/user/getAllAdmins").permitAll()
                .antMatchers("/api/**").hasAnyAuthority(AuthoritiesConstants.CLIENT, AuthoritiesConstants.ADMIN, AuthoritiesConstants.WORKER)
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .loginPage("/")
                .loginProcessingUrl("/")
                .permitAll();
Run Code Online (Sandbox Code Playgroud)

和控制器方法的例子:

@RequestMapping(value = "/api/vehicle")
@PreAuthorize("hasAnyAuthority('ADMIN', 'CLIENT')")
@RequestMapping(value = "", method = RequestMethod.GET)
public List<VehicleReservationModel> getVehiclesForClientByLogin(HttpServletRequest request) {
    Principal name = request.getUserPrincipal();
    if (name.getName() == null) {
        throw new RuntimeException("Brak …
Run Code Online (Sandbox Code Playgroud)

authentication authorization spring-security

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

Gitignore 不适用于 .xml 文件和 /target 目录

我有两个.gitignore文件,因为一个在过去不起作用,我不得不创建第二个;他们看起来:

/target/
.idea/
Run Code Online (Sandbox Code Playgroud)

.gitignore.gitignore它看起来:

*/target/**
/target/**
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
target/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
.idea/

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
Run Code Online (Sandbox Code Playgroud)

它仍然包括那些文件.gitignore- 为什么?在此处输入图片说明

git intellij-idea gitignore

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