web工程中各类地址写法的总结
时间:2014-01-16 00:01:34
收藏:0
阅读:416
首先打一个"/"
//如果地址给服务器用,那么"/"就代表该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">
*/
原文:http://www.cnblogs.com/E-star/p/3516457.html
评论(0)