我正在使用 Eclipse 来使用 Jersey 实现 REST Web 服务。我希望所有通信都在 https 中。所以,我将我的 web.xml 编辑为
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>com.myapp.server</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.myapp.server</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.myapp.server.webservices.security.SecurityFilter</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- Security constraint for the sample application -->
<security-constraint id="SecurityConstraint_1">
<!-- This defines the REST resource associated with the constraint. -->
<web-resource-collection id="WebResourceCollection_1">
<web-resource-name>Jersey REST Service</web-resource-name>
<description>Protection area for Rest resource / </description>
<url-pattern>/rest/*</url-pattern>
</web-resource-collection>
<user-data-constraint id="UserDataConstraint_1">
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
然后在使用 normal 进行测试时http://localhost:8080/com.myapp.server/rest/user/all
,它会重定向到https://localhost:8443/com.myapp.server/rest/user/all
. 然后我找不到页面。我究竟做错了什么?无论如何要解决这个问题?