我遇到组件AjaxFormComponentUpdatingBehavior
的问题。
当我将此组件添加到主页面时,spring security会启用授权,作为受保护的页面。当我从页面中删除此组件时,一切都会变好。
我的UNSECURED_RESOURCE_LIST“/ resources / ”,“/ assets / ”,“/ css / ”, “/ fonts / ”,“/ webjars / ”,“/ img / ”,“/ js /**”。
这是我的wicket页面,正如您在添加AjaxFormComponentUpdatingBehavior组件时所看到的,spring security启用了授权。
public class FrontPage extends WebPage {
private List<Language> languages = Arrays.asList(Language.RUSSIAN,
Language.ENGLISH);
private Language language = Language.RUSSIAN;
private DropDownChoice languagesDD;
public FrontPage() {
languagesDD = new DropDownChoice<String>("languages", new
PropertyModel(FrontPage.this, "language"), new
PropertyModel(FrontPage.this, "languages"), new ChoiceRenderer() {
@Override
public Object getDisplayValue(Object object) {
Language language = (Language) object;
if (Language.RUSSIAN.equals(language)) {
return getString("Language.RUSSIAN");
} else if (Language.ENGLISH.equals(language)) {
return getString("Language.ENGLISH");
}
return super.getDisplayValue(object);
}
});
add(languagesDD);
languagesDD.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//iWebSession().setLocaleString(language.getCode());
//setResponsePage(FrontPage.class);
}
});
}
}
答案 0 :(得分:0)
When i comment this component. Everything become OK. I guess that maybe the AjaxFormComponentUpdatingBehavior component is trying to use the resources that are in the protected area. I added the resources to the non-security list. So I cannot understand why spring enables authorization when I add AjaxFormComponentUpdatingBehavior component.
public class FrontPage extends WebPage {
private List<Language> languages = Arrays.asList(Language.RUSSIAN,
Language.ENGLISH);
private Language language = Language.RUSSIAN;
private DropDownChoice languagesDD;
public FrontPage() {
languagesDD = new DropDownChoice<String>("languages", new PropertyModel(FrontPage.this, "language"), new PropertyModel(FrontPage.this, "languages"), new ChoiceRenderer() {
@Override
public Object getDisplayValue(Object object) {
Language language = (Language) object;
if (Language.RUSSIAN.equals(language)) {
return getString("Language.RUSSIAN");
} else if (Language.ENGLISH.equals(language)) {
return getString("Language.ENGLISH");
}
return super.getDisplayValue(object);
}
});
add(languagesDD);
// languagesDD.add(new AjaxFormComponentUpdatingBehavior("change") {
// @Override
// protected void onUpdate(AjaxRequestTarget target) {
// //iWebSession().setLocaleString(language.getCode());
// //setResponsePage(FrontPage.class);
// }
// });
}
}
答案 1 :(得分:0)
好的,我找到了解决方案。 只需将“/ wicket / **”添加到不安全的资源列表中即可。