我创建了一个简单的表单,我想向其中添加一个验证器:
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) 我用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 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) 我有两个.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)
angular ×2
git ×1
gitignore ×1
package ×1
spring ×1
spring-boot ×1
typescript ×1
validation ×1