web工程中分客户端浏览器要访问的地址和服务器要访问的地址。浏览器要访问的地址是url,服务器要访问的是服务器端的相对位置。如:
1.request.getRequestDispatcher("/index.jsp");
2.response.sendRedirect("/day05/form.html");
3.this.getServletContext().getRealPath("/download/日本纽.jpg");
4.this.getServletContext().getResourceAsStream("/download/日本纽.jpg");
5.<a href='/day05/index.jsp'>点点</a>
<form action='/day05/servlet/ResponseDemo1'></form>
<img src='/day05/download/日本纽.jpg'>
一般先在前面打个/,然后看是谁访问。
注:url用斜杠“/”,磁盘上得目录用反斜杠"\"