如何通过超链接进入到jsp中web-inf下的页面

通过表单进入到web-inf下的页面,这个比较了解,但是通过超链接进入还是第一次,今天又学了一个方法。

首先在超链接处这样写★管理选手☆,然后新建一个servlet,

package cn.edu.hpu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PlayerServlet extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			String url=request.getParameter("url"); 
			request.getRequestDispatcher(url).forward(request, response); 
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		 doGet(request, response);
	}
}

注意不要忘了在web.xml里边配置信息:


    This is the description of my J2EE component
    This is the display name of my J2EE component
    PlayerServlet
    cn.edu.hpu.servlet.PlayerServlet
  

    PlayerServlet
    /PlayerServlet
  


你可能感兴趣的:(java)