標籤:tomcat
安裝後tomcat伺服器後,登陸首先就是讓輸入使用者名稱和密碼,可是我們在安裝tomcat的過程中好像沒有讓設定使用者名稱和密碼,這時候可能有人就抓狂了,還有的人是突然忘記了使用者名稱和密碼,對於出現這種情況該怎麼去解決呢?
不慌,tomcat安裝的過程中是沒有讓使用者佈建使用者名稱和密碼,因為這個工作是需要使用者自己在設定檔中自己書寫的。過程如下:
以我安裝tomcat的目錄為例 D:\Program Files\apache-tomcat-6.0.35
進入該目錄找到conf檔案下,找到tomcat-users.xml檔案,用記事本開啟它
然後在<tomcat-users></tomcat-users>中間添加<user username="" password="" roles="manager"/>
<tomcat-users><!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary.--><!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them.--><!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/>--><user username="" password="" roles="manager"/> </tomcat-users>
上述代碼中引號可以自己設定使用者名稱和密碼,如果按照我上面所寫的代表是沒有使用者名稱和密碼
這下子大家都清楚了嗎?
安裝好了tomcat,下面就是怎麼將自己的項目部署到tomcat上了
首先在MyEclipse中將tomcat設定好 設定的方法和地方如所示
分別設定JDK 載入方式 Paths不用設定
設定好後,將自己的項目部署到tomcat伺服器上,可以利用IDE MyEclipse來部署,或者直接手動在server.xml中自動部署
開啟剛才的tomcat安裝的conf檔案夾 找到server.xml 開啟在其中加下如下代碼即可
<Context path="/struts2" docBase="D:\MyEclipse 10 WorkSpace\struts2\WebRoot" reloadable="true" />
其中 struts2是項目名稱 docBase是該項目的路徑 reloadable表示當修改設定檔等伺服器自動重新載入
這樣,啟動伺服器即可。
給新手--安裝tomcat後使用者名稱和密碼設定以及項目怎麼部署在tomcat伺服器上