我正在按照此示例进行春季和运行: http://static.springsource.org/docs/spring-mvc-step-by-step/part2.html

他们要做的是将所有.JSP文件移入Web-Inf中,以阻止用户直接访问它们……到目前为止还不错。但是,Servlet有一个index.jsp的欢迎页面,当将其移动到Web-Inf Dir中时,我会遇到错误。我无法确定Tomcat 6是否应该允许欢迎页面进入Web-Inf?

有帮助吗?

解决方案

Web-Inf内部的任何内容都无法直接访问,但是必须首先通过其他内容(通常是Servlet),然后将请求内部转发到Web-Inf资源。

其他提示

我正在尝试同一教程。本教程没有这么说,但是我将Web.xml中的值从“ index.jsp”更改为“/web-inf/jsp/index.jsp”。

我使用这种技术(适用于Servlet API> = 2.4):

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
    <url-pattern>/index.htm</url-pattern>    <<==  *1*
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.htm</welcome-file>   <<== *2*
</welcome-file-list>

所以你不再需要 redirect.jsp 和:

<% response.sendRedirect("/myproject/MyAction.action"); %>

在非 -WEB-INF 目录!!

这里有两个具有相同技术的博客:

更新SRV.9.10 Welcome Files 部分 Servlet API 2.4 文档^

The purpose of this mechanism is to allow the deployer to specify an ordered
list of partial URIs for the container to use for appending to URIs when there is a
request for a URI that corresponds to a directory entry in the WAR not mapped to
a Web component. This kind of request is known as a valid partial request.

The use for this facility is made clear by the following common example: A
welcome file of `index.html' can be defined so that a request to a URL like
host:port/webapp/directory/, where `directory' is an entry in the WAR that is
not mapped to a servlet or JSP page, is returned to the client as `host:port/
webapp/directory/index.html'.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top