私のfaviconは突然すべて動作しているようです。私はそれが失敗に始まる原因となった変更を確認していないが、それはうまくレンダリングするために使用され、今はそれが文字化けしている。Faviconが正しくレンダリングされていない、文字化けしているように見える
ここでそれがどのように見えるかのサンプルです:
私は春のブートを使用していますし、現れて、あなたのファビコンを取得する方法上のすべての一般的な答えを見つけるために周りGoogleで検索している...しかし、私は運がなかった。
faviconのURLにアクセスすると、ブラウザにアイコンとしてロードされず、代わりにテキストの束として読み込まれることがわかりました(これが正常かどうかはわかりません)。
は、ここで私は私のローカルホストを訪問したときに何が起こるかです:8080/favicon.icoを用URL:私はそれを考えることができる唯一のことは、私が最近変更した
に影響を持っていたかもしれませんfaviconは私のWebSecurityConfig.javaでした...私はREALMと基本認証を追加しました。あなたがこれを考え出した場合
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Autowired
private UserDetailsService userDetailsService;
private static String REALM="MY_TEST_REALM";
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void globalSecurity (AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception
{
// authenticate/authorize
// authentication = who the hell are you? i.e. username/password
// authorization = what can you access in the app?
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/*").permitAll()
.antMatchers("/js/**").permitAll()
.antMatchers("/webinars/**").permitAll()
.antMatchers("/img/**").permitAll()
.antMatchers("/fonts/**").permitAll()
.antMatchers("/register").permitAll()
.antMatchers("/samcart").permitAll()
.antMatchers("/sales").permitAll()
.antMatchers("/sales/**").permitAll()
.antMatchers("/paypal/**").permitAll()
.antMatchers("/forgotPassword").permitAll()
.antMatchers("proffesso-favicon.ico").permitAll()
.antMatchers("/students/purchasedCourse.html").permitAll()
.antMatchers("/students/courses/**").permitAll()
.antMatchers("/teachers/courses/*/image").permitAll()
.antMatchers("/teachers/courses/*/offers/*/image").permitAll()
.antMatchers("/handlebars/**").permitAll()
.antMatchers("/css/**").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.httpBasic()
.realmName(REALM)
.authenticationEntryPoint(getBasicAuthEntryPoint())
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/students/courses")
.successHandler(new NoRedirectSavedRequestAwareAuthenticationSuccessHandler())
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/").permitAll()
.and()
.sessionManagement()
.maximumSessions(1);
}
@Bean
public CustomBasicAuthenticationEntryPoint getBasicAuthEntryPoint(){
return new CustomBasicAuthenticationEntryPoint();
}
/* To allow Pre-flight [OPTIONS] request from browser */
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean()
public SecurityEvaluationContextExtension securityEvaluationContextExtension() {
return new SecurityEvaluationContextExtension();
}
}
私はICOファイルの代わりにPNGファイルを指しているようですが、正しくレンダリングします。 – Trevor
通常、ChromeにICOファイルのURLを入力すると、正しく表示できます。ここではバイナリデータをテキストとして表示します。あなたのサーバから返されたMIMEタイプ(image/vnd.microsoft.iconでなければなりません)を調べるよう助言します。 –