Hi I'm trying to set up a static error page for 404 not found errors on app engine.
According to https://developers.google.com/appengine/docs/java/config/webxml#Error_Handlers: it says 404 cannot be customized.
And according to: https://developers.google.com/appengine/docs/java/config/appconfig#Custom_Error_Responses it don't seem to support 404 too.
However, https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/3C-pY5ta2HQ, seems to suggest that 404 error page can be customised. I'm confused right now.
i realised this problem happens when running the app on local dev server. however, when i deploy the app to app engine. i can see the 404 error page that was configured using web.xml. thanks for all your help.
Why don't you use a Java EE <error-page> entry for these purposes?
in your web.xml:
<error-page>
<error-code>404</error-code>
<location>/app/error/404</location>
</error-page>
....
<error-page>
<error-code>500</error-code>
<location>/app/error/500</location>
</error-page>
You can combine it with Spring and get a general error-controller like:
....
@Controller
public class ErrorController {
@RequestMapping(value = "/error/{errorCode}")
public final String errorCode(
@PathVariable("errorCode") final String errorCode,
final ModelMap modelMap) {
modelMap.put("statusCode", errorCode);
return "redirect:/ui/error.htm";
}
and your jsp-like file:
<h2>Error!!!</h2>
....
<h3>Status code: #{param.statusCode}</h3>
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With