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

为何无法访问Tomcat中/webapps/Root下的xx.jsp文件?

Hey there! Let's break down why your xx.jsp is throwing a 404 error while xx.html loads just fine—here are the most common causes and fixes to check:

Possible Reasons & Solutions for JSP 404 in Tomcat
  • Incorrect file placement
    Make sure your xx.jsp is in the right directory. If you're accessing it via http://localhost:8080/xx.jsp, it needs to live directly in the ROOT folder (same location as the working index.jsp). If you put it in a subfolder, you'll need to include that path in your URL, like http://localhost:8080/your-subfolder/xx.jsp.

  • Missing JSP servlet mapping
    Tomcat relies on a built-in servlet to process .jsp files. Check your Tomcat conf/web.xml file for this default mapping—if it's missing or modified, Tomcat won't know how to handle JSP requests. Look for this section:

    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>
    

    If it's not there, add it back (you might need to restart Tomcat afterward).

  • File extension typos
    Double-check the exact filename—case matters on systems like Linux. Accidental typos like xx.JSP or xx.js will cause a 404, since Tomcat only recognizes lowercase .jsp by default. HTML files are more forgiving because they're served as static content regardless of case (usually).

  • Tomcat didn't detect the new file
    If you added the JSP while Tomcat was running, try restarting the server. Some configurations don't auto-detect new JSP files on the fly. You can also verify if autoDeploy="true" is set in the <Host> element of your conf/server.xml—this enables automatic deployment of new files without a restart.

  • File permission issues
    Ensure the Tomcat process has read access to your xx.jsp file. On Linux/macOS, run chmod 644 xx.jsp to set read permissions, and chown tomcat:tomcat xx.jsp (adjust the user/group to match your Tomcat setup) to give the server ownership. On Windows, make sure the file isn't marked as read-only.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:19:58