The origin server did not find a current representation for the target resource or is not willing to

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

一开始不知道为什么。甚至连http://localhost:8080/ 都打不开。也一直报同样的错误。

解决方案

1. 查看tomcat 服务器。双击窗口中服务器   

看到   server locations 选项为灰色,不可选 ,且为第一个: 


接下来 做的是:删除服务器里面的项目, 删除服务器  。 点击添加服务器 连接,选择tomcat 版本,添加项目。 




 此时在双击服务器,看到 

server locations 可选,勾选中间一个。  



重新build 后 ,访问还是不能访问,报同样的错误,但是 localhost:8080已经可以访问了。不报错了。

2.检查jsp文件 

网上百度了很多,发现不行。然后检查自己写的jsp文件。发现 jsp文件是放在WEB-INF 文件夹下面的。 WEB-INF文件下的 jsp文件用户是不能直接访问到的。好像是受保护的。

因此把jsp文件 挪到  WebContent文件下即可了。


正确做法是放在 WebContent 文件夹下面。 自己弄错了。希望自己谨记。

若想放到文件夹里面 也是把jsp 文件 放到 WebContent 下面的文件夹里面 。

访问路径为: localhost:8080 / 你的项目名称 / 你的放jsp的文件夹/jsp文件名称.jsp 

如:http://localhost:8080/JSTLTest/jsp/JSTLTest.jsp 


第一个JSTLTest 为项目名称,jsp 为 WebContent 下面的 文件夹,专门存放 jsp文件的。 然后 第二个 JSTLTest为jsp文件。需要加后缀。

原文链接:https://blog.csdn.net/yushiww/article/details/74421476

猜你喜欢

转载自blog.csdn.net/xudasong123/article/details/79705969