2016-03-03 82 views
0

时,导航至错误jsp我已将以下过滤器和过滤器映射添加到web.xml文件。当我的Java应用程序阻止访问jsp

<filter> 
    <filter-name>Remote Address Filter</filter-name> 
    <filter-class>org.apache.catalina.filters.RemoteAddrFilter</filter-class> 
    <init-param> 
     <param-name>allow</param-name> 
     <param-value>127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1</param-value> 
    </init-param> 
</filter> 
<filter-mapping> 
    <filter-name>Remote Address Filter</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

这只允许访问来自本地主机引擎的调用。这是有效的,因为当我尝试从另一个位置运行时,我在我的浏览器中收到以下内容:HTTP 403 - 禁止

但我想在此情况下重定向到我的错误页面,以下方式:

<error-page> 
    <location>/error.jsp</location> 
</error-page> 

如何实现这个?

回答

0

你忘了指定<error-code>

<error-page> 
    <error-code>403</error-code> 
    <location>/error.jsp</location> 
</error-page> 
+0

我加了它,但它并没有改变任何东西。 – Jonas

相关问题