tomcat服务器配置及使用

序:tomcat作为免费开源的web服务器,广受大家喜欢,但是该如何使用此服务器呢?下面就一步一步教大家操作tomcat服务器

一、权限配置

编辑tomcat-users.xml文件配置tomcat服务器权限,此文件所在路径:%tomcat_home%/conf/tomcat-users.xml

在此配置文件中有两个比较重要的节点:

一个是<role rolename=""></rolename>

role中有几种比较重要的角色,这几种角色都跟管理Application有关。

  • manager-gui — Access to the HTML interface.访问HTML接口
  • manager-status — Access to the "Server Status" page only. 仅能访问服务器状态
  • manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
  • manager-jmx — Access to JMX proxy interface and to the "Server Status" page.

下面这几种角色具体作用不详。

tomcat

role1

admin-gui

另一个是<user username="" password="" roles=""></user>

username和password不用说了,就是登陆时用到的用户名和密码。

roles属性可以填多个role,用半角英文逗号隔开。 

二、web.xml

服务中的web.xml是很重要的一个配置文件,一定要是小写的web.xml,大写的服务器就不会认识

配置Servlet,Filter,Listener等的都是在这个文件中配置

举个Servlet配置的例子

<web-app>   
<servlet>   
    <servlet-name>hello</servlet-name>   
    <servlet-class>hello.Hello</servlet-class> 
</servlet>   
<servlet-mapping>   
    <servlet-name>hello</servlet-name>   
    <url-pattern>/lookhello</url-pattern>   
</servlet-mapping>
</web-app>

 

posted @ 2015-11-09 23:37  初级编程  阅读(443)  评论(0编辑  收藏  举报