0

我有一个 web.xml,它看起来像:

<web-app>

<welcome-file-list>
   <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Default</web-resource-name>
    <url-pattern>/</url-pattern>
  </web-resource-collection>
  <auth-constraint/>
</security-constraint>

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Index page</web-resource-name>
    <url-pattern>/index.jsp</url-pattern>
    <url-pattern>/</url-pattern>
    <http-method>GET</http-method>
    <http-method>HEAD</http-method>
  </web-resource-collection>
</security-constraint>
...

我们希望默认拒绝对资源的访问,并指定我们希望允许访问的资源。

如果用户访问http://localhost:8080/他们会被拒绝访问,但是,如果访问 http://localhost:8080/index.jsp它允许他们进入。两个 URL 应该显示相同的页面,并且两者应该被允许。我在这里做错了什么?

4

1 回答 1

4

我认为要做的事情是指定/*捕获默认值,并执行特定的模式,例如捕获不是index.jsp/somethingElse.jsp的任何其他页面。希望您的顶级“目录”不是很混乱。

于 2009-12-15T07:29:35.537 回答