Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 设置反向安全约束_Java_Security_Jsp - Fatal编程技术网

Java 设置反向安全约束

Java 设置反向安全约束,java,security,jsp,Java,Security,Jsp,我正在尝试向后设置安全约束。我想说,除了我指定的页面之外,所有页面都需要登录。我使用: <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>*&

我正在尝试向后设置安全约束。我想说,除了我指定的页面之外,所有页面都需要登录。我使用:

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

/*
*

但是我不知道如何说index.jsp不需要登录

放置所有安全页面
/secure
并将安全筛选器配置为
/secure/*
,或者在筛选配置中创建排除。以下示例基于spring security:

<http auto-config='true'>
    <intercept-url pattern="/index.jsp*" filters="none"/>
</http>


简单的答案是,使用web.xml无法实现这一点(可以说是一件好事,因为安全机制最好尽可能简单)。正如@Johan所说,保护一些url模式,如
/secure/*
/app/*
,并将所有页面放在那里。

虽然这是100%正确的,但OP询问的是web.xml部署描述符,并没有表明他们正在使用spring安全性。由于web.xml约束是在容器级别强制执行的,因此这两种方法也不容易混合使用。