关耳er  

一、目录展示

  

 

 二、aindex.jsp

  

三、AServlet

  

package com.zn;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/AServlet")
public class AServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //重定向
        /*resp.sendRedirect("/aindex.jsp");*/
        //302状态码
        resp.setStatus(302);
        resp.setHeader("Location","aindex.jsp");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}

四、效果展示

  访问路径:

  

  跳转到aindex.jsp

  

posted on 2020-02-04 17:06  关耳er  阅读(144)  评论(0编辑  收藏  举报