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

IntelliJ IDEA中Tomcat 8.5启动JSP报404资源不可用,配置排查无效求助

Troubleshooting Tomcat 8.5 + IntelliJ IDEA JSP 404 Error

Hey there, let’s work through this 404 issue you’re hitting when launching JSPs in IntelliJ IDEA with Tomcat 8.5. Even after checking configuration classes, there are a few common gotchas in artifact setup and web.xml that often slip through the cracks. Let’s break them down:

1. Audit Your Tomcat Artifact Configuration

First, let’s make sure your artifact is deployed correctly in IDEA:

  • Check Deployment Descriptors: Open File > Project Structure > Artifacts and verify that your web.xml is listed under "Deployment Descriptors"—it shouldn’t be grayed out, and the file path should point to the correct WEB-INF/web.xml in your project.
  • Validate Output Directory: Ensure the artifact’s output path matches what Tomcat expects. IDEA often uses out/artifacts/[your_project_name] by default; confirm this directory contains your compiled classes, JSP files, and WEB-INF folder. If not, reconfigure the artifact to include all necessary resources.
  • Confirm Context Root: The Context Root setting in the artifact configuration dictates the base URL for your app. For example, if it’s set to /my-web-app, you’ll need to access your JSP at http://localhost:8080/my-web-app/your-page.jsp—not just the root /your-page.jsp. A mismatch here is one of the most common 404 causes.

2. Dig Into web.xml Settings

Next, let’s rule out issues in your deployment descriptor:

  • Welcome File List: If you’re hitting 404 when accessing the default homepage, check that your web.xml includes the correct JSP in <welcome-file-list>:
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    
    Double-check that index.jsp actually exists in your webapp root directory (not inside WEB-INF).
  • Servlet Mapping Validation: If your JSP is accessed via a servlet, confirm the url-pattern matches the path you’re using. For example:
    <servlet>
        <servlet-name>HomeServlet</servlet-name>
        <servlet-class>com.example.HomeServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>HomeServlet</servlet-name>
        <url-pattern>/home</url-pattern>
    </servlet-mapping>
    
    Also, ensure the servlet’s forward path is correct (e.g., request.getRequestDispatcher("/WEB-INF/views/home.jsp").forward(request, response)—paths here are relative to the webapp root).
  • web.xml Placement: Make sure web.xml is located directly in the WEB-INF folder of your webapp directory (usually src/main/webapp/WEB-INF in Maven/Gradle projects). IDEA won’t recognize it if it’s in the wrong place.

3. Quick Additional Checks

  • JSP File Location: JSPs inside WEB-INF can’t be accessed directly via URL—they need to be forwarded by a servlet. If you’re trying to hit a JSP directly, move it to the webapp root or a subfolder outside WEB-INF.
  • Clean & Rebuild: Sometimes IDEA’s cached files cause deployment issues. Run Build > Clean Project, then Build > Rebuild Project, and restart Tomcat.
  • Check Tomcat Logs: Head to your Tomcat installation’s logs folder and look at localhost.log or catalina.out—these logs often include specific details about which resource Tomcat is failing to find, which can pinpoint the issue fast.

Give these steps a shot—most of the time, this 404 error boils down to a small misconfiguration in artifact setup or web.xml. Let me know if any of these fix your problem!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 10:19:32