[Java][Web]Web 工程中的各类地址的写法

// 1.

request.getRequestDispatcher("/index.html").forward(request,response);

// 以 / 开头,对于浏览器 / 表示网站,对于服务器 / 表示当前的 web应用

// 反斜杠 用于访问硬盘资源的路径分隔符

// 2.

response.sendRedirect("/day05/index.html");

// 3.

this.getServletContext().getRealPath("/index.html");

// 4.

this.getServletContext().getResourceAsStream("/public/foot.jsp");

// 5. html / jsp 页面

<a href="/day06/index.html">链接</a>

<form action="/day06/index.html">表单</form>

原文地址:https://www.cnblogs.com/z5337/p/6864234.html