web工程中各类地址写法的总结

首先打一个"/"

//如果地址给服务器用,那么"/"就代表该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">
*/

上一篇:html5 01 随记


下一篇:ubuntu 学习