You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Dynamic Web Project时出现Error 404问题求助

Dynamic Web Project 404 Error Troubleshooting

Hey folks, I just created a Dynamic Web Project named DynamicPages, but every time I run it on the server, I get an Error 404 with this message:

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

Here's my web.xml content (it got truncated a bit):

<?xml version="1.0" encoding="UTF-8"?> 
<element> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.j...

Let's work through the common fixes for this issue:

  • Verify your access URL matches the context root: Make sure you're using the correct URL that points to your project's context root. For example, if your project's context root is /DynamicPages, your access URL should be http://localhost:8080/DynamicPages/your-page.jsp (or the default welcome page path). Don't just hit the server root without specifying your project's context.
  • Check welcome file configuration in web.xml: If you haven't set up a default welcome page, the server won't know which page to load by default. Add this section to your web.xml:
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    
  • Confirm the project is deployed successfully: Head to your server's management console (like Tomcat's Manager App) to check if DynamicPages is deployed without errors. If deployment failed, it could be due to compilation issues or missing dependencies.
  • Fix web.xml syntax errors: Wait a minute—your web.xml starts with an <element> tag, which is invalid for Java EE web applications! The root tag should only be <web-app>. That extra <element> will cause the server to fail parsing the configuration, which is probably the main reason for the 404. Remove that tag immediately so your web.xml starts correctly with <web-app>.
  • Check your page file locations: Ensure your JSP/HTML files are placed under the WebContent (or src/main/webapp for Maven projects) directory. Files in the Java source directory won't be deployed as accessible web resources.

内容的提问来源于stack exchange,提问作者Kkunal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:03:54