У меня есть 4 разные страницы с ошибками для моей заявки на калитку.Метод WebRequestCycle.onRuntimeException:
@Override
public final Page onRuntimeException(Page cause, RuntimeException runtimeException) {
if (runtimeException instanceof EMSUserNotFoundException) {
return new EMSUserNotFoundExceptionPage(runtimeException);
} else if (runtimeException instanceof EMSUnreachableException) {
return new EMSUnreachableExceptionPage(runtimeException);
} else if (runtimeException instanceof UserActionPortInitializationException) {
return new UserActionPortInitializationExceptionPage(runtimeException);
} else {
return new GeneralRunTimeExceptionPage(runtimeException);
}
}
Во время выполнения EMSUserNotFoundExceptionPage, EMSUnreachableExceptionPage, GeneralRunTimeExceptionPage отображаются для соответствующих случаев.Но цикл запроса не перенаправляет на страницу UserActionPortInitializationExceptionPage.Я думал, что UserActionPortInitializationExceptionPage имеет некоторые проблемы, поэтому я удаляю GeneralRunTimeExceptionPage из else и помещаю туда UserActionPortInitializationExceptionPage, затем я увидел эту страницу.
Теперь UserActionPortInitializationException:исключение:
public static String getUserActionPortAddress() {
String userActionPortAddress = null;
ClassPathResource userActionPortAddressResource = new ClassPathResource("port-address.properties");
Properties properties = null;
try {
properties = loadProperties(userActionPortAddressResource.getFile());
} catch (Exception e) {
throw new UserActionPortInitializationException();
}
if (properties != null) {
userActionPortAddress = properties.getProperty("port");
}
if (userActionPortAddress == null) {
throw new UserActionPortInitializationException();
}
return userActionPortAddress;
}
private static Properties loadProperties(File file) throws Exception {
InputStream is = null;
Properties props = new Properties();
try {
is = new FileInputStream(file);
props.load(is);
} finally {
is.close();
}
return props;
}
Когда UserActionPortInitializationException генерируется приложением в консоли, я получаю:
Caused by: release.exception.UserActionPortInitializationException: UserActionPort initialization failed
Это означает, что исключение генерируется этим фрагментом, но я не могу понять, почемустраница не перенаправляется.
Для получения дополнительной информации:
UserActionPortInitializationExceptionPage.java:
public class UserActionPortInitializationExceptionPage extends ExceptionBasePage {
public UserActionPortInitializationExceptionPage(RuntimeException runtimeException) {
super(runtimeException);
}
}
UserActionPortInitializationExceptionPage.html:
<html xmlns:wicket>
<body>
<wicket:extend>
<h1 style="font-size: 1.5em; color: red;">UserActionPort initialization failed</h1>
<i>Please contact administrator</i>
</wicket:extend>
</body>
Спасибо и С уважением.