Spring MIME类型(';text/html';)不可执行,并且启用了严格的MIME类型检查
我写的网站,一切工作,但当我添加下一页所有网站下跌。 我收到以下信息:Spring MIME类型(';text/html';)不可执行,并且启用了严格的MIME类型检查,spring,Spring,我写的网站,一切工作,但当我添加下一页所有网站下跌。 我收到以下信息: localhost/:1 Refused to execute script from 'http://localhost:8080/js/jquery-1.12.3.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. localhost/:1 Refused to e
localhost/:1 Refused to execute script from 'http://localhost:8080/js/jquery-1.12.3.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:8080/js/modalWindow.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:8080/js/jquery-ui.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:8080/js/jquery.validate.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:8080/css/1/js-image-slider.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:8080/css/bootstrap/js/bootstrap.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
我尝试添加另一个页面,但它是相同的。
此外,我看不到我所有的图片,网站在“static”目录中找不到路径(backgrounds/phone32.png)。
我不明白我在哪里能找到这个问题的解决办法。
本主页:
@Controller
public class MainController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView viewMainPage() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("index");
return modelAndView;
}
}
此代码将显示另一页:
@Controller
public class ClothFabricController {
@Autowired
private ClothFabricService service;
@RequestMapping(name = "/cloth", method = {RequestMethod.GET})
public ModelAndView seeCloth(){
ModelAndView modelAndView = new ModelAndView();
List<ClothFabricDTO> dtos = service.seeAllCloth();
modelAndView.addObject("allCloth", dtos);
modelAndView.setViewName("allFabric/clothFabric");
return modelAndView;
}
}
我今天也犯了同样的错误,但我在一个Wordpress网站上工作。它正在使用
gulp
进行构建。我在项目中添加了一个新文件,并开始出现此错误。但是,当我停止大口喝,做了一个大口喝构建
之后,一个大口喝手表
一切都很好。希望这有帮助。我今天也犯了同样的错误,但我在Wordpress网站上工作。它正在使用gulp
进行构建。我在项目中添加了一个新文件,并开始出现此错误。但是,当我停止大口喝,做了一个大口喝构建
之后,一个大口喝手表
一切都很好。希望这有帮助。
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Autowired
private UserRepository userRepository;
@Autowired
private DataSource dataSource;
@Override
protected void configure(final HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests()
.antMatchers("/css/**", "/js/**", "/image/**")
.permitAll()
.antMatchers("/backgrounds/**")
.permitAll()
.antMatchers("/registrationPage")
.permitAll()
.antMatchers("/")
.permitAll()
.antMatchers("/testo")
.permitAll()
.antMatchers("/addRadio")
.permitAll()
.antMatchers("/cloth")
.permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/")
.passwordParameter("password")
.permitAll()
//благодаря этой строчке при logout кидает на индекс, если ее удрать будет кидать на logout
.and().logout().logoutSuccessUrl("/")
.and()
.httpBasic()
.and()
.csrf().disable();
httpSecurity.rememberMe().rememberMeParameter("remember-me")
.rememberMeCookieName("my-remember-me")
.tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400000);
httpSecurity.addFilterBefore(authenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}
// JDBC Authentication
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
//receive login(userDetailsService) and password (passwordEncoder) from DB
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new MyPasswordEncoder();
}
public IsAccountNonExpiredFilter authenticationFilter() throws Exception {
IsAccountNonExpiredFilter authFilter = new IsAccountNonExpiredFilter();
authFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/login","POST"));
authFilter.setAuthenticationManager(super.authenticationManager());
authFilter.setAuthenticationSuccessHandler(new SimpleUrlAuthenticationSuccessHandler("/"));
authFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login?error"));
authFilter.setUsernameParameter("username");
authFilter.setPasswordParameter("password");
authFilter.setUserRepository(userRepository);
return authFilter;
}
@Bean
public PersistentTokenRepository persistentTokenRepository() {
JdbcTokenRepositoryImpl tokenRepository = new JdbcTokenRepositoryImpl();
tokenRepository.setDataSource(dataSource);
return tokenRepository;
}
}