//目标资源: target.html
/**
* 思考: 目标资源是给谁使用的。
* 给服务器使用的: / 表示在当前web应用的根目录(webRoot下)(转发)
* 给浏览器使用的: / 表示在webapps的根目录下 (重定向、超链接、action)
*/
/**
* 1.转发
*/
// request.getRequestDispatcher("/target.html").forward(request, response);
/**
* 2.重定向
*/
// response.sendRedirect("/WEB_Servlet/target.html");
response.sendRedirect(request.getContextPath()+"/aa_Login.html");
/**
* 3.html页面的超连接href
*/
response.getWriter().write("<html><body><a href='/day11/target.html'>超链接</a></body></html>");
/**
* 4.html页面中的form提交地址
*/
response.getWriter().write("<html><body><form action='/day11/target.html'><input type='submit'/></form></body></html>");
java中“ . ”表示当前运行的项目
javaweb 中“ . ”表示Tomcat运行目录,在tomcat/bin目录下开始
所以在Javaweb 如果要查找src目录下的文件怎么办,
String path=this.getServletContext().getRealPath("/WEB-INF/classes/db.properties");
得到的path: “F:\jee-neon\javaEE_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\WEB_Servlet\WEB-INF\classes\db.properties
”