我想限制只有GET/Request/path/rest/*的域。所以我宣佈它在我的web.xml:在web.xml中聲明http-method不會阻止其他http方法
<security-constraint>
<web-resource-collection>
<web-resource-name>All</web-resource-name>
<url-pattern>/rest/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Auth</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
然而,做一個POST請求到(例如)當「/ REST /添加」,那麼Web容器接受並提交POST請求。爲什麼?
當瀏覽到:localhost/section/a.html時,我不允許通過'/ *'在web.xml中聲明資源。但是,我可以通過'/ rest/*'聲明訪問'localhost/rest/myresource'而不進行身份驗證。所以代碼並不是完全無用的。 – nimo23 2012-08-01 10:42:13
我沒有第二個http方法,但我限制了對已認證角色的訪問。 – nimo23 2012-08-01 10:44:14
這是否意味着,我應該只改變兩個安全約束的順序? – nimo23 2012-08-01 10:44:57