您index.jsp
在 web 根文件夹中。如果您请求显示此文件夹,并且 Web 服务器发现该index.jsp
文件夹中有重定向到index.jsp
. 这段代码来自Tomcat的web.xml
:
<!-- ==================== Default Welcome File List ===================== -->
<!-- When a request URI refers to a directory, the default servlet looks -->
<!-- for a "welcome file" within that directory and, if present, to the -->
<!-- corresponding resource URI for display. -->
<!-- If no welcome files are present, the default servlet either serves a -->
<!-- directory listing (see default servlet configuration on how to -->
<!-- customize) or returns a 404 status, depending on the value of the -->
<!-- listings setting. -->
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure to include any of the default values that you wish -->
<!-- to use within your application. -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
如果您index.jsp
从根文件夹中删除,如果您的代码正确映射到操作,则它可能会起作用。您可能还会发现这个问题Can Struts 2 First Page 来自引擎,而不是列出它并回答对您有用。