Response.sendRedirect () Precautions

xiaoxiao2021-03-06  54

Sutance with Response.sendredirect is actually sending a special header to the browser, then makes the browser to turn to the specified page, so when using SendRedire, you can see the address of the address on the browser.

Unlike

So just pay attention to the following two points when using response.sendredirect:

1. When using Response.sendredirect, there is no HTML output in front.

This is not absolute, can't have HTML output, but it does not have HTML to be sent to the browser. In fact, SERVER has a Cache mechanism, usually at 8K (I am JSP Server), which means that unless you shut down cache, or you use out.flush () forced refresh, then before using Sendredirect, There are small amounts of HTML outputs are also allowed.

If an error is said, "some information has been Submitted" (original text forgot), then you have to pay attention, do you have too much HTML output in front.

2, after response.sendredirect,

Should follow a Return;

We already know that response.sendredirect is turned through a browser, so there is only actual actions only after the page processing is completed. Since you have already turned to turn, what is the significance of the post-output? And it is possible that the steering failure is caused by the back of the output.

转载请注明原文地址:https://www.9cbs.com/read-114654.html

New Post(0)