我想让 HTTP 重定向在 WebSphere Application Server Liberty Profile (WLP) 上工作。例如:-
当用户键入:
http://localhost:8080/helloworld
时,浏览器应该自动转到(被重定向)到
https://localhost:9443/helloworld
为了实现这一点,我遵循了这个文档,第 6.2 节,第 1 页。136.
下面是示例 server.xml 和 web.xml:-
服务器.xml
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>wab-1.0</feature>
<feature>jaxrs-1.1</feature>
<feature>blueprint-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>ssl-1.0</feature>
<feature>appSecurity-2.0</feature>
</featureManager>
<httpEndpoint host="localhost" httpPort="8081" httpsPort="9442" id="defaultHttpEndpoint">
</httpEndpoint>
<applicationMonitor updateTrigger="mbean"/>
<keyStore id="defaultKeyStore" password="{xor}Lz4sLCgwLTtu"/>
<application id="Hello.app" location="Hello.app.eba" name="Hello.app" type="eba"/>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Hello</display-name>
<security-constraint>
<display-name>HTTPS Redirect Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Sample Web Service service</web-resource-name>
<url-pattern>/Hello</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>
为简洁起见,删除了<servlet>
and<servlet-mapping>
标签。
以下是我正在使用的版本:- Java 7、WLP 8.5.5、Eclipse Juno、Google Chrome。
任何有关 HTTPS 重定向为何不起作用的帮助和指南将不胜感激。