我有使用Spring安全的Web应用程序。
当我在tomcat9
上运行我的应用时,一切正常,但是什么时候
我使用oracle Weblogic出错了,app中的js脚本无效。
拒绝执行“http://localhost:7001/ais/s/lib/datetime/js/moment-with-locales.min.js”脚本,因为其MIME类型(“application/octet-stream
”)不可执行,并且启用了严格的MIME类型检查。
这是我的安全配置:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
UserService service;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/s/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.permitAll();
}
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.userDetailsService(new UserDetailServiceImpl(service));
}
}
答案 0 :(得分:1)
I just solve it by putting to SecurityConfig this
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/s/**");
}
答案 1 :(得分:0)
Add a weblogic deployment descriptor in WEB-INF folder.Build your project and deploy. In my case my xml look like.
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<debug>true</debug>
</jsp-descriptor>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
<context-root>/ContextRootOfYourApp</context-root>
</weblogic-web-app>