您的位置:首页 > 运维架构 > Tomcat

idea运行项目tomcat运行报错 404

2020-06-29 04:52 1031 查看

我们在用IDEA运行项目时会出现这种情况
使用severlet时报错:The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.( 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。



解决方法

这种原因一般是因为我们用idea创建sverlet时软件并没有给我们创建配置文件,所以导致我们的tomcat运行项目时找不到运行的服务和servlet的地址。

配置文件在这个地方

我们可以在配置文件上添加这几行代码

<servlet>
<servlet-name>StudentServlet</servlet-name>
<servlet-class>com.xgxy.servlet.StudentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/StudentServlet</url-pattern>
</servlet-mapping>

这里servlet-name里面的StudentServlet就是服务的名字
servlet-class里面的com.xgxy.servlet.StudentServlet是服务StudentServlet的路径
servlet-mapping下面的url-pattern里面的/StudentServlet是项目运行时在网址栏显示的地址
我们在写项目时添加servlet时需要在配置文件web.xml中自己吧这四行代码写上去才可以运行服务

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: