2010年09月02日 星期四 下午 5:25
一、在容器中设置 tomcat中配置server.xml中定义context时采用如下定义: <Context path="/livsorder" docBase="/home/httpd/html/livsorder" weblogci中设置weblogic特有部署描述符weblogic.xml的<session-descriptor>元素的 二、web应用设置,优先级比容器中高 设置web应用程序描述符web.xml里的<session-timeout>元素。这个值以分钟为 三、应用代码中设置,优先级最高 jsp中控制
|
<web-app>
<security-constraint>
<web-resource-collection>
<display-name>Example Security Constraint</display-name>
<web-resource-name>My Test</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>role1</role-name>
<role-name>tomcat</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>My Test</realm-name>
</login-config>
<web-app>
其中,<url-pattern>中指定受限的url,可以使用通配符*,通常对整个目录进行访问权限控制。
<auth-constraint>中指定哪些角色可以访问<url-pattern>指定的url,在<role-name>中可以设置一个或多个角色名。
使用的角色名来自tomcat的配置文件${CATALINA_HOME}/conf/tomcat-users.xml。
<login-config>中设置登录方式,<auth-method>的取值为BASIC或FORM。如果为BASIC,浏览器在需要登录时弹出一个登录窗口。如果为FORM方式,需要指定登录页面和登录失败时的提示信息显示页面。