如何在404 Tomcat上重定向到外部网站 [英] How to redirect to external website on 404 Tomcat
本文介绍了如何在404 Tomcat上重定向到外部网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Spring 3 + Tomcat 7
I am using spring 3 + Tomcat 7
在web.xml
中我已定义
<error-page>
<error-code>404</error-code>
<location>/filenotfound</location>
</error-page>
但是我想重定向到外部URL说www.google.com
而不是/filenotfound
.我该怎么办?
But i want to redirect to external url say www.google.com
instead of /filenotfound
. How can I do that ?
推荐答案
我不确定在位置中提供直接URL是否可行.但是您可以在其中放置一个jsp,然后从该jsp重定向到该网址.
I am not sure whether giving the direct url in location will work. But you can put a jsp there and redirect to the url from the jsp.
<error-page>
<error-code>404</error-code>
<location>/filenotfound.jsp</location>
</error-page>
filenotfound.jsp
filenotfound.jsp
<%@ page language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:redirect url="http://hotmail.com" />
这篇关于如何在404 Tomcat上重定向到外部网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文