春季安全配置的问题

时间:2016-03-10 03:15:14

标签: spring spring-security

我试图配置Spring Security。

这是我的sucurity配置。

for (int i = 0; i< 3; i++)
{    
    ((System::Windows::Forms::CheckBox ^)Controls->Find("CheckBox"
        + System::Convert::ToString(i+1), true)[0])->Checked = false;
}

当我访问url“localhost:8080 / admin”时,我希望“/ denied”页面。 但它显示默认的403页提供弹簧安全性。 我的配置有问题吗?

1 个答案:

答案 0 :(得分:1)

更新: 将import org.apache.spark.mllib.classification.{SVMModel, SVMWithSGD} import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics import org.apache.spark.mllib.util.MLUtils // Load training data in LIBSVM format. val data = MLUtils.loadLibSVMFile(sc, "data/mllib/sample_libsvm_data.txt") // Split data into training (60%) and test (40%). val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L) val training = splits(0).cache() val test = splits(1) // Run training algorithm to build the model val numIterations = 100 val model = SVMWithSGD.train(training, numIterations) // Clear the default threshold. model.clearThreshold() // Compute raw scores on the test set. val scoreAndLabels = test.map { point => val score = model.predict(point.features) (score, point.label) } // Get evaluation metrics. val metrics = new BinaryClassificationMetrics(scoreAndLabels) val auROC = metrics.areaUnderROC() println("Area under ROC = " + auROC) // Save and load model model.save(sc, "myModelPath") val sameModel = SVMModel.load(sc, "myModelPath") 更改为.anyRequest().denyAll()

.anyRequest().authenticated()

如果您需要使用@Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http.authorizeRequests() .antMatchers("/api/**", "/denied**").permitAll() .anyRequest().authenticated() .and() .exceptionHandling().accessDeniedPage("/denied") .and() .csrf().disable(); // @formatter:on } ,只需在requiresSecure()之后添加.requiresChannel().anyRequest().requiresSecure().and()