【发布时间】:2015-02-02 19:33:53
【问题描述】:
我知道,答案如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>All resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
它工作得很好,但前提是它是 web.xml 中唯一的一个安全约束。
一旦我添加了第二个安全约束,就会出现这样的情况:
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin section</web-resource-name>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>USER</role-name>
</auth-constraint>
</security-constraint>
重定向对指向管理部分的 URL 停止工作(在这种情况下,应用程序显示登录表单)。
有没有办法通过 web.xml 或 wildfly 配置全局启用重定向?
PS:用wildfly 8.2测试
【问题讨论】:
-
你可以配置你的服务器强制HTTPS
-
@Rafael:以什么方式?
-
@Rafael:该链接是关于 Apache url 重写的。我的问题是关于 servlet 或 wildfly 配置。
-
@Rafael:事情没那么简单。仅当您使用默认端口(80 和 443)或您已经知道必须使用的端口时,该方法才有效。该信息存储在standalone.xml 中,但Web 应用程序无法访问它。
标签: java web-applications web.xml wildfly