switchpage.java

来自「软件开发过程通常包括五个阶段:分析、设计、编码、测试和发布。如果在Web应用开发」· Java 代码 · 共 84 行

JAVA
84
字号
/* * SwitchPage.java * * Created on 2005年3月1日, 上午12:23 */package test.action;import java.io.*;import java.net.*;import javax.servlet.*;import javax.servlet.http.*;import test.bean.WhoLogin;/** * * @author Administrator * @version */public class SwitchPage extends HttpServlet {        /** Initializes the servlet.     */    public void init(ServletConfig config) throws ServletException {        super.init(config);            }        /** Destroys the servlet.     */    public void destroy() {            }        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.     * @param request servlet request     * @param response servlet response     */    protected void processRequest(HttpServletRequest request, HttpServletResponse response)    throws ServletException, IOException {        String id = request.getParameter("id");        String toPage;        WhoLogin whoLogin = new WhoLogin();        whoLogin.setId(id);        if(whoLogin.getName().equals("your name is A")){            toPage = "a.html";        } else if(whoLogin.getName().equals("your name is B")){            toPage = "b.html";        } else if(whoLogin.getName().equals("your name is C")){            toPage = "c.html";        } else{            toPage = "other.html";        }        getServletConfig().getServletContext().getRequestDispatcher("/" + toPage).forward(request,response);    }        /** Handles the HTTP <code>GET</code> method.     * @param request servlet request     * @param response servlet response     */    protected void doGet(HttpServletRequest request, HttpServletResponse response)    throws ServletException, IOException {        processRequest(request, response);    }        /** Handles the HTTP <code>POST</code> method.     * @param request servlet request     * @param response servlet response     */    protected void doPost(HttpServletRequest request, HttpServletResponse response)    throws ServletException, IOException {        processRequest(request, response);    }        /** Returns a short description of the servlet.     */    public String getServletInfo() {        return "Short description";    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?