首页 > 解决方案 > Cannot resolve variable _csrf in Spring MVC Application

问题描述

i have been trying to add xss protection via including the code

 <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>

While execution it passes

<input type="hidden" name="" value=""/>

My SecurityConfig File is

@Configuration
@EnableWebSecurity
public class DemoSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                    .loginPage("/app/")
                    .loginProcessingUrl("/app/login")
                    .permitAll();
    }
}

Is there anything i want to add?

标签: spring-mvcspring-bootspring-securitycsrfcsrf-protection

解决方案


推荐阅读