1.在Tomcat中添加如下代码
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="C:/keystore.jks"
keystorePass="123456" />
其中keystoreFile:是你生成的key或者购买的SSL证书,keystorePass:是证书的密码
2.在web.xml中添加如下代码:
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
具体的配置可查考http://blog.csdn.net/buster2014/article/details/47185459的文章
将 URL 映射设为 /* ,这样你的整个应用都要求是 HTTPS 访问,而 transport-guarantee 标签设置为 CONFIDENTIAL 以便使应用支持 SSL。
如果你希望关闭 SSL ,只需要将 CONFIDENTIAL 改为 NONE 即可
参考:http://www.cnblogs.com/moon521/p/5948058.html