web工程中各类地址的写法
(1).request.getRequestDispatcher("/form1.html").forward(request,response);给服务器用的
(2).response.sendRedirect("/day05/form1.html");给浏览器用的
(3).this.getServletContext().getRealPath("/form1.html");给服务器用的
(4).this.getServletContext().getResourceAsStream("/form1.html");给服务器用的
(5).<ahref="/day05/form1.html">ddd</a>给浏览器用的
(6).<formaction="/day05/form1.html"></form>给浏览器用的
总结:
1、在浏览器端建议使用el表达式,来动态获取web应用的绝对路径的位置
2、写地址以斜杠开头,如果地址是给浏览器用的,这个斜杠代表一个网站,
如果是给服务器用的,这个斜杠代表web应用.浏览器向服务器发送请求,就是给浏览器用的