且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用网络浏览器密码保存

更新时间:2023-11-27 21:43:28

您基本上需要将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>

另请参见: