Tomcat web.xml配置已经常用功能说明2008年06月02日 星期一 00:16五、web.xml配置简介:
1、默认(欢迎)文件的设置
在tomcat4\conf\web.xml中,<welcome-file-list>与IIS中的默认文件意思相同。
2、报错文件的设置
如果某文件资源没有找到,服务器要报404错误,按上述配置则会调用\webapps\ROOT\notFileFound.jsp。
如果执行的某个JSP文件产生NullPointException ,则会调用\webapps\ROOT\null.jsp
3、会话超时的设置
设置session 的过期时间,单位是分钟;
4、过滤器的设置
过滤:
1) 身份验证的过滤Authentication Filters
2) 日志和审核的过滤Logging and Auditing Filters
3) 图片转化的过滤Image conversion Filters
4) 数据压缩的过滤Data compression Filters
5) 加密过滤Encryption Filters
6) Tokenizing Filters
7) 资源访问事件触发的过滤Filters that trigger resource access events XSL/T 过滤XSL/T filters
9) 内容类型的过滤Mime-type chain Filter 注意监听器的顺序,如:先安全过滤,然后资源,
然后内容类型等,这个顺序可以自己定。
六、管理
1、用户配置
在进行具体Tomcat管理之前,先给tomcat添加一个用户,使这个用户有权限来进行管理。
打开conf目录下的tomcat-users.xml文件,在相应的位置添加下面一行:
<user name="user" password="user" roles="standard,manager"/>
然后重起tomcat,在浏览器中输入[color=blue]http://localhost:8080/manager/[/color],会弹出对话框,输入上面的用户
名和密码即可。
2、应用程序列表
在浏览器中输入[color=blue]http://localhost:8080/manager/list[/color],浏览器将会显示如下的信息:
OK - Listed applications for virtual host localhost
/ex:running:1
/examples:running:1
/webdav:running:0
/tomcat-docs:running:0
/manager:running:0
/:running:0
上面显示的信息分别为:应用程序的路径、当前状态、连接这个程序的session数
3、重新装载应用程序
在浏览器中输入 [color=blue]http://localhost:8080/manager/reload?path=/examples[/color],浏览器显示如下:
OK - Reloaded application at context path /examples
这表示example应用程序装载成功,如果我们将server.xml的Context元素的reloadable属性设为true,则没必要利用这种方式重新装载应用程序,因为tomcat会自动装载。
4、显示session信息
在浏览器中输入[color=blue]http://localhost:8080/manager/sessions?path=/examples[/color],浏览器显示如下:
OK - Session information for application at context path /examples Default maximum session inactive
interval 30 minutes
5、启动和关闭应用程序
在浏览器中输入[color=blue]http://localhost:8080/manager/start?path=/examples[/color]和
[color=blue]http://localhost:8080/manager/stop?path=/examples[color]分别启动和关闭examples应用程序
1、默认(欢迎)文件的设置
在tomcat4\conf\web.xml中,<welcome-file-list>与IIS中的默认文件意思相同。
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
2、报错文件的设置
<error-page>
<error-code>404</error-code>
<location>/notFileFound.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/null.jsp</location>
</error-page>
如果某文件资源没有找到,服务器要报404错误,按上述配置则会调用\webapps\ROOT\notFileFound.jsp。
如果执行的某个JSP文件产生NullPointException ,则会调用\webapps\ROOT\null.jsp
3、会话超时的设置
设置session 的过期时间,单位是分钟;
<session-config>
<session-timeout>30</session-timeout>
</session-config>
4、过滤器的设置
<filter>
<filter-name>FilterSource</filter-name>
<filter-class>project4. FilterSource </filter-class>
</filter>
<filter-mapping>
<filter-name>FilterSource</filter-name>
<url-pattern>/WwwServlet</url-pattern>
(<url-pattern>/haha/*</url-pattern>)
</filter-mapping>
过滤:
1) 身份验证的过滤Authentication Filters
2) 日志和审核的过滤Logging and Auditing Filters
3) 图片转化的过滤Image conversion Filters
4) 数据压缩的过滤Data compression Filters
5) 加密过滤Encryption Filters
6) Tokenizing Filters
7) 资源访问事件触发的过滤Filters that trigger resource access events XSL/T 过滤XSL/T filters
9) 内容类型的过滤Mime-type chain Filter 注意监听器的顺序,如:先安全过滤,然后资源,
然后内容类型等,这个顺序可以自己定。
六、管理
1、用户配置
在进行具体Tomcat管理之前,先给tomcat添加一个用户,使这个用户有权限来进行管理。
打开conf目录下的tomcat-users.xml文件,在相应的位置添加下面一行:
<user name="user" password="user" roles="standard,manager"/>
然后重起tomcat,在浏览器中输入[color=blue]http://localhost:8080/manager/[/color],会弹出对话框,输入上面的用户
名和密码即可。
2、应用程序列表
在浏览器中输入[color=blue]http://localhost:8080/manager/list[/color],浏览器将会显示如下的信息:
OK - Listed applications for virtual host localhost
/ex:running:1
/examples:running:1
/webdav:running:0
/tomcat-docs:running:0
/manager:running:0
/:running:0
上面显示的信息分别为:应用程序的路径、当前状态、连接这个程序的session数
3、重新装载应用程序
在浏览器中输入 [color=blue]http://localhost:8080/manager/reload?path=/examples[/color],浏览器显示如下:
OK - Reloaded application at context path /examples
这表示example应用程序装载成功,如果我们将server.xml的Context元素的reloadable属性设为true,则没必要利用这种方式重新装载应用程序,因为tomcat会自动装载。
4、显示session信息
在浏览器中输入[color=blue]http://localhost:8080/manager/sessions?path=/examples[/color],浏览器显示如下:
OK - Session information for application at context path /examples Default maximum session inactive
interval 30 minutes
5、启动和关闭应用程序
在浏览器中输入[color=blue]http://localhost:8080/manager/start?path=/examples[/color]和
[color=blue]http://localhost:8080/manager/stop?path=/examples[color]分别启动和关闭examples应用程序