JSP网站如何做301重定向?

时间:2021-03-26 13:39:28
大家好,请问下JSP网站如何做301重定向呢,听说不同的主机做301重定向的方法也不一样的,怎么看网站使用的是Linux还是windows主机啊?

2 个解决方案

#1


public class TestServlet extends HttpServlet {

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
}
}

#2


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
 response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);   
response.setHeader("Location","/other.jsp");
return;
%>

随带一个连接http://www.diybl.com/course/4_webprogram/jsp/jsp_js/20091125/183440.html

#1


public class TestServlet extends HttpServlet {

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
}
}

#2


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
 response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);   
response.setHeader("Location","/other.jsp");
return;
%>

随带一个连接http://www.diybl.com/course/4_webprogram/jsp/jsp_js/20091125/183440.html