禁用网络浏览器密码保存 [英] Disable web browser password save

查看:116
本文介绍了禁用网络浏览器密码保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用JSF 2.0创建的简单登录页面.通常,在每个登录页面中,Web浏览器都会向用户建议保存其用户名密码.

I have a simple Login page made with JSF 2.0. Usually in every login page the web browser proposes to the user to save his username a password.

我在Oracle网站上看到用户必须进行身份验证,当我输入用户名和密码时,浏览器不会询问我是否要保存用户名和密码.也许有一种方法可以从登录页面的代码中禁用它.

I saw in Oracle's web site where user must authenticate that when I enter my username and password the browser do not ask me do I want to save my username and password. Maybe there is a way to disable this from the code of the login page.

这可能吗?

推荐答案

您基本上需要将autocomplete="off"属性添加到HTML <form>元素中.但是,<h:form>不支持此属性.仅单个<h:inputText><h:inputSecret>组件支持.

You basically need to add autocomplete="off" attribute to the HTML <form> element. However, this attribute is not supported on the <h:form>. It's only supported on the individual <h:inputText> and <h:inputSecret> components.

所以,这应该做:

<h:form>
    <h:inputText value="#{auth.username}" required="true" autocomplete="off" />
    <h:inputSecret value="#{auth.password}" required="true" autocomplete="off" />
    <h:commandButton value="Login" action="#{auth.login}" />
    <h:messages />
</h:form>

<h:form>上新的autocomplete属性计划用于JSF 2.2.另请参见 JSF规范问题418 .

The new autocomplete attribute on <h:form> is scheduled for JSF 2.2. See also JSF spec issue 418.

或者,如果您正在使用j_security_check的容器管理登录名,无论如何,该登录名都需要普通的HTML <form>,则只需将其添加到其中:

Or, if you're using container managed login with j_security_check which requires a plain vanilla HTML <form> anyway, then just add it in there:

<form action="j_security_check" method="post" autocomplete="off">
    <input type="text" name="j_username" />
    <input type="password" name="j_password" />
    <input type="submit" value="Login" />
</form>

另请参见:

  • <h:inputText>标记文档(提及autocomplete属性)
  • <h:inputSecret>标记文档(提及autocomplete属性)
  • See also:

    • <h:inputText> tag documentation (mentions autocomplete attribute)
    • <h:inputSecret> tag documentation (mentions autocomplete attribute)
    • 这篇关于禁用网络浏览器密码保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆