gpt4 book ai didi

jsp - 处理 JSP 页面中的 response.redirect 错误

转载 作者:行者123 更新时间:2023-12-04 22:11:55 26 4
gpt4 key购买 nike

我有一个 URL 被恶意操纵或更改的情况。我必须捕获错误并移至错误页面。但永远不会调用错误页面。

我正在使用 response.sendRedirect("MyURL");在jsp页面中。如果 URL 正确,则其工作正常。

如果我操作 URL 并使用命令,它会在同一页面中显示 HTTP 404 错误,但不会调用错误页面

这是我的代码。

one.jsp  
---------
<%@ page errorPage="exceptionHandler.jsp" %>
<%

String webBrowserURL="http://URL"

response.sendRedirect(webBrowserURL);

%>


exceptionHandler.jsp
------------------------

<%@ page isErrorPage="true" %>
<% String root = request.getContextPath(); %>

<%
//get the correct url form the database and send it to the page
%>


<jsp:forward page="one.jsp" />

帮帮我

最佳答案

因此,如果 URL 正确且重定向工作正常,那么您为什么期望它使用不正确的 URL?

检查您使用的 URL 是否正确,并确保您没有在 JSP 上打印任何内容,例如 out.println("something") 或者在调用重定向之前您没有任何 HTML 代码。

关于jsp - 处理 JSP 页面中的 response.redirect 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2361559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com