自动填充(自动完成)不适用于Safari中的“电子邮件”字段

时间:2018-08-04 15:12:44

标签: html forms

我有一个带有电子邮件地址和提交按钮的简单表格。 Chrome会自动填充电子邮件字段,但Safari不会。知道为什么吗?!

@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {

    @Autowired
    CredentialsService credentialsService;

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        return credentialsService.authenticate(authentication);
    }

    @Override
    public boolean supports(Class<?> authentication) {
        boolean value = (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
        return value;
    }

}

可能相关:

  • 页面上有时还有另一个电子邮件表单字段(用于新闻通讯注册),但是即使将其删除,它仍然不起作用。
  • 我删除了public AuthenticationFromCredentialsFilter authenticationFromCredentialsFilter() throws Exception { AuthenticationFromCredentialsFilter authenticationFromCredentialsFilter = new AuthenticationFromCredentialsFilter(); authenticationFromCredentialsFilter.setAuthenticationManager(authenticationManagerBean()); authenticationFromCredentialsFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/api/users/login")); return authenticationFromCredentialsFilter; } public AuthenticationFromTokenFilter authenticationFromTokenFilter() throws Exception { AuthenticationFromTokenFilter authenticationFromTokenFilter = new AuthenticationFromTokenFilter(); authenticationFromTokenFilter.setAuthenticationManager(authenticationManagerBean()); authenticationFromTokenFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/**")); return authenticationFromTokenFilter; } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); http.headers().cacheControl().disable().frameOptions().disable(); http.httpBasic().authenticationEntryPoint(restAuthenticationEntryPoint); http.addFilterBefore(simpleCORSFilter, UsernamePasswordAuthenticationFilter.class); http.antMatcher("/api/**") .addFilterBefore(authenticationFromCredentialsFilter(), UsernamePasswordAuthenticationFilter.class) .addFilterBefore(authenticationFromTokenFilter(), UsernamePasswordAuthenticationFilter.class) .authorizeRequests() .antMatchers("/").permitAll() .antMatchers("/error").permitAll() .antMatchers("/api/users/login").permitAll() .antMatchers("/admin/**").hasRole(UserDomainConstants.ROLE_ADMIN) .anyRequest().authenticated(); } ,它可以在Safari ONCE中使用,但我无法复制它。
  • 网站上其他地方的另一个字段(文本搜索)也不会在Safari中自动填充,尽管在Chrome中也是如此。

1 个答案:

答案 0 :(得分:0)

我也有同样的问题(在移动 Safari 上),您可以尝试将自动完成选项设置为“电子邮件”(如此处所述 The HTML autocomplete attribute),如下所示:autocomplete="email"。此选项修复了(在我的情况下)电话字段的自动完成功能,但仍然无法帮助在移动设备上自动完成电子邮件字段。