xx.jsp在根目录下,图片的路径为:<img height="33" src="images/enter.gif" width="148">
xx.jsp在根目录的某文件夹下,图片的路径应为:<img height="33" src="../images/enter.gif" width="148"> //注意斜杠前面是两点
xx.jsp在根目录下,提交给servlet的路径应为<form action="login" method="post">
xx.jsp在根目录的某文件夹下,提交给servlet的路径应为:<form action="/ajaxStudy/login" method="post"> //绝对路径?
web配置文件为:
<servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>p21.LoginServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>LoginServlet</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping>
//这样写的话,无论文件是放在 根目录下还是普通目录下都可以访问得到。
<img height="33" src="<%=request.getContextPath() %>/images/enter.gif" width="148">