Wicket中的错误页面出现问题。 我们使用Wiket(8.0.0-M8)和spring security(4.2.3.RELEASE)。
我知道如何设置我的错误页面,但标准页面也不起作用(我得到错误页面tomcat,而不是我的。)
getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class);
特性是可以指定页面500(内部错误)。但其余的则没有。
Spring Security没有页面403(访问被拒绝页面),如果您在Spring中指定并且在Wicket中指定了mountPage,它将发送到404。 如何申报404也不完全清楚。
UPD:web.xml:
<display-name>project</display-name>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>transactionFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>transactionFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>transactionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>wicket.project</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
</init-param>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>ru.company.project.web.WicketApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.project</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
答案 0 :(得分:1)
以下是如何使用Spring Boot执行此操作:
versionCode
在MySpringConfiguration.java中:
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
import org.springframework.boot.web.servlet.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
public class MyErrorPageRegistrar implements ErrorPageRegistrar {
@Override
public void registerErrorPages(final ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,
MyApplication.PAGE_NOT_FOUND_MOUNT_PATH));
}
}
在MyApplication.java中:
@Bean
public ErrorPageRegistrar errorPageRegistrar(){
return new MyErrorPageRegistrar();
}