ตัวอย่างรหัส:
<%@ page language = "java" contentType = "text/html; charset = utf-8" pageencoding = "utf-8"%> <%// ไปที่ iq.jspout.clearbuffer (); response.setstatus request.getQueryString (); Response.Setheader ("ตำแหน่ง", "iq.jsp"+(param == null? ":("? "+param)));%> <%@ page language = "java" contentType = "ข้อความ/html; charset = utf-8" pageencoding = "utf-8"%> <%// ไปที่ iq.jsp out.clearbuffer (); Response.setStatus (httpservletResponse.sc_moved_permanently); String param = request.getQueryString (); Response.Setheader ("ตำแหน่ง", "iq.jsp"+(param == null? ":("? "+param))); %> ดังที่ได้กล่าวไว้ข้างต้นการเข้าถึงทั้งหมดเพื่อดาวน์โหลด JSP จะเข้าถึงและเปลี่ยนเส้นทางไปยัง iq.jsp ได้อย่างถาวร
พารามิเตอร์จะถูกดำเนินการในเวลาเดียวกัน
หากการเปลี่ยนเส้นทางของคุณเป็น cross-domain หรือใช้เส้นทางเต็มคุณสามารถใช้
Response.Setheader ("ตำแหน่ง", "http://www.laozizhu.com/iq.jsp"+(param == null? "" :( "?"+param))); Response.Setheader ("ตำแหน่ง", "http://www.laozizhu.com/iq.jsp"+(param == null? "" :( "?"+param)));วิธีนี้คุณสามารถระบุชื่อโดเมนการหมุนเวียนที่สมบูรณ์
วิธีการทั่วไปคือการกระโดด 302 ครั้ง:
Response.sendredirect (http://www.baidu.com);
Response.sendredirect ("http://www.baidu.com");