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">
*/

 

 

posted @ 2014-01-12 19:20  E_star  阅读(267)  评论(0编辑  收藏  举报