域名直接訪問項目|Tomcat http 自動跳轉Https


1.域名直接訪問項目

 案例:tomcat下域名直接訪問項目,或者說,修改tomcat默認歡迎頁

 (1).修改server.xml

         添加: <Context path="" docBase="C:\TOOL\apache-tomcat-8.0.51\webapps\home\" debug="0"/>  目標地址指到:你的項目根路徑下C:\TOOL\apache-tomcat-8.0.51\webapps\home\

 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

    <Context path="" docBase="C:\TOOL\apache-tomcat-8.0.51\webapps\home\" debug="0"/> 
       
      </Host>

(2).修改web.xml

你的初始頁面是什么,就改成什么,我的還是index.html,所以保持不變,你的要是login.html,添加一行

<welcome-file>login.html</welcome-file>
<welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

重啟,就OK

2.http 自動跳轉https

主要修改兩方面:

(1).修改server.xml

 

 所有跳轉,全部轉成443

(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> 

重啟就OK了  

-----------------------------------------------------分割線-------------------------------------------------------------

 點擊鏈接:先領劵,在支付,點我哦

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM