jsp如何在Java中捕获HTTP 404
我有一个web应用程序,我有一个问题 如果我的应用程序中不存在该网页,我将得到以下错误页面
HTTP Status 404 - /myapplication/department/home.html
type Status report
message /myapplication/department/home.html
description The requested resource (/myapplication/department/home.html) is not available.
我想把用户转发到索引页,如果这个问题发生了,他不知道怎么做
# 1 楼答案
只需在
web.xml
中将索引页指定为404默认错误页我假设你知道这对用户体验和SEO不好?例如,如果您已经(重新)移动了一个页面,那么您应该创建一个过滤器,将301重定向到所需的位置