您好,登錄后才能下訂單哦!
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//重定向 302 與localhost 響應頭(服務-》客戶端)
public class Demo extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
////服務端通知客戶端重定向
response.setStatus(302);
//服務端通知客戶端重定向的目標資源
response.setHeader("location", "WEB-INF/my.html");
}
}
新建 my.html
<!DOCTYPE html>
<html>
<head>
<title>my.html</title>
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
localhost+302
</body>
</html>
訪問
輸入地址:
http://localhost:8080/day04/Demo
結果成如下
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。