有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Tomcat身份验证要求重新登录,即使浏览器尚未关闭

我在Tomcat下运行的web应用程序中使用摘要身份验证。 我注意到,每隔一段时间它就会要求我重新登录:要求我输入用户名和密码的弹出窗口就会再次出现。 如何防止这种行为?我只想在第一次打开网站时登录

我注意到,在web浏览器上进行多次刷新后,会发生这种情况。如果没有刷新,那么它将不会再次要求我输入用户名和密码。我认为只要我不关闭浏览器,默认行为就不会再次要求我进行身份验证。我的理解正确吗

我不确定这是否有帮助,但我已尝试在我的web中将会话超时设置为-1。xml文件,但它似乎没有帮助

<session-config>  
    <session-timeout>-1</session-timeout>  
</session-config>  

这是完整的网络。xml:

 <?xml version="1.0" encoding="ISO-8859-1"?>

 <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://java.sun.com/xml/ns/j2ee    
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">  

<resource-env-ref>
    <description>user db</description>
    <resource-env-ref-name>UserDatabase</resource-env-ref-name>
    <resource-env-ref-type>org.apache.catalina.UserDatabase</resource-env-ref-type>
</resource-env-ref>


<security-constraint>
    <web-resource-collection>
        <web-resource-name>user-resource</web-resource-name>
        <description>pages which require login</description>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.html</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description>Must authenticate before querying the system</description>
        <role-name>admin</role-name>      
    </auth-constraint>


    <user-data-constraint>
          <transport-guarantee>NONE</transport-guarantee>       
    </user-data-constraint>
</security-constraint>

<login-config>
    <auth-method>DIGEST</auth-method>
</login-config>  

<session-config>
    <session-timeout>-1</session-timeout>
</session-config>
</web-app>

共 (0) 个答案