首先打一个"/"

//如果地址给服务器用,那么"/"就代表该web应用 , 如果给浏览器用的,那么"/"就代表网站(其下有多个web应用)

//1
request.getRequestDispatcher("/index.jsp").forward(request, response); //给服务器用的
//2
response.sendRedirect("/Test/index.jsp"); //给浏览器用的
//3
this.getServletContext().getRealPath("/download/1.jsp"); //给服务器用的
//4:
this.getServletContext().getResource("/download/1.jsp"); //给服务器用的
//5 浏览器用的
/*
* <a href = "/Test/Servlet">
* <form action="/Test/Servlet">
*/

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2022-02-10
  • 2022-01-21
  • 2021-08-02
  • 2021-10-23
相关资源
相似解决方案