Web applications 如何启用SSL我的web应用程序?

Web applications 如何启用SSL我的web应用程序?,web-applications,ssl,tomcat7,Web Applications,Ssl,Tomcat7,我已将以下代码放在tomcat的server.xml文件中: <Connector SSLEnabled="true" clientAuth="false" keystoreFile="D:\keystore.jks" keystorePass="****" maxThreads="150" port="8443" protocol="HTTP/1.1" scheme="https" secure="true" sslProtocol="TLS" /> 我的

我已将以下代码放在tomcat的server.xml文件中:

<Connector SSLEnabled="true" clientAuth="false"
    keystoreFile="D:\keystore.jks" keystorePass="****" maxThreads="150"
    port="8443" protocol="HTTP/1.1" scheme="https" secure="true"
    sslProtocol="TLS" />
我的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_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>RPM</display-name>
    <welcome-file-list>
        <welcome-file>admin</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>RPM</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>

转速
管理
调度员
org.springframework.web.servlet.DispatcherServlet
调度员
/
转速
/*
保密的
dispatcher-servlet.xml代码

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd" >

    <context:component-scan base-package="com.rpm.controller" />
    <mvc:annotation-driven />
    <mvc:resources mapping="/css/**" location="/css/*"/>
    <mvc:resources mapping="/js/**" location="/js/*"/>
    <mvc:resources mapping="/images/**" location="/images/*"/>

    <!-- Beans to be autowired - START-->
    <bean class="com.rpm.beans.Clinic"/>
    <bean class="com.rpm.beans.PatientGroup"/>
    <bean class="com.rpm.beans.Clinician"/>
    <!-- Beans to be autowired - END-->


    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" >
        <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" >
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles/tiles.xml</value>
            </list>
        </property>
    </bean>
</beans>

/WEB-INF/tiles/tiles.xml

例外是因为安全管理器与ssl无关。

Spring在这个问题中起到了什么作用?您是否尝试将TLS与只包含“Hello World”JSP的普通war一起使用?@Tichodroma否我没有尝试,但从错误中可以看出,它在尝试访问已部署的类文件时遇到问题。所以我觉得我错过了一些我没有也不知道的事情。如果有什么帮助的话,我已经添加了dispatcher-servlet.xml代码。谢谢,我找到了它。我无意中检查了Eclipse上出现的tomcat控制台中的“启用安全性”
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd" >

    <context:component-scan base-package="com.rpm.controller" />
    <mvc:annotation-driven />
    <mvc:resources mapping="/css/**" location="/css/*"/>
    <mvc:resources mapping="/js/**" location="/js/*"/>
    <mvc:resources mapping="/images/**" location="/images/*"/>

    <!-- Beans to be autowired - START-->
    <bean class="com.rpm.beans.Clinic"/>
    <bean class="com.rpm.beans.PatientGroup"/>
    <bean class="com.rpm.beans.Clinician"/>
    <!-- Beans to be autowired - END-->


    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" >
        <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" >
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles/tiles.xml</value>
            </list>
        </property>
    </bean>
</beans>