在使用新版本的IDEA時,使用Jakarta EE創(chuàng)建模板Web應用程序后,在訪問Hello Servlet時出現404 Not found。
這里我使用的是Tomcat 9.0.x的應用服務器,在代碼邏輯完全沒有問題的情況下,依然出現404 Not found。
在與之前的代碼對比之后,發(fā)現在使用以下依賴會導致這樣的情況。
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
修改為以下依賴后可以正常訪問。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
可以看到,在這之后可以正常訪問資源。文章來源:http://www.zghlxwxcb.cn/news/detail-757155.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-757155.html
到了這里,關于Servlet出現“HTTP狀態(tài) 404 - 未找到”問題解決方案(特例)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!