Eclipse下Web项目路径跳转

项目结构如下:

src                : com.restaurant.servlet --> RegisterServlet

WebContent : ch03                            -->  register.jsp

浏览器输入 localhost:8080/项目名/ch03/register.jsp 要跳转到src 下的RegisterServlet

使用相对路径 jsp中应该这样写:action="/restaurant/servlet/RegisterServlet"

使用绝对路径 没办法访问 只能改用相对路径

一句话:

相对路径:         起始就是发起跳转的文件的所在路径 localhost:8080/项目名/xxx.jsp----localhost:8080/项目名/xxxServlet

绝对路径:加 /    路径的起始就是服务器IP地址  localhost:8080/项目名/xxx.jsp----localhost:8080/项目名/xxxServlet

参考博客:https://www.wandouip.com/t5i210656/

猜你喜欢

转载自www.cnblogs.com/liupengjuan/p/10968977.html
今日推荐