Javascript Spring安全weblogic js加载
我有一个带有Spring security的web应用程序 当我在tomcat9上运行我的应用程序时,一切正常,但 我使用OracleWebLogic时出现了一些问题,我的应用程序中的js脚本无法工作 拒绝从“”执行脚本,因为其MIME类型(“Javascript Spring安全weblogic js加载,javascript,spring,spring-security,weblogic,weblogic11g,Javascript,Spring,Spring Security,Weblogic,Weblogic11g,我有一个带有Spring security的web应用程序 当我在tomcat9上运行我的应用程序时,一切正常,但 我使用OracleWebLogic时出现了一些问题,我的应用程序中的js脚本无法工作 拒绝从“”执行脚本,因为其MIME类型(“application/octet stream”)不可执行,并且启用了严格的MIME类型检查 这是我的安全配置: @Configuration @EnableWebSecurity public class SecurityConfig extends
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));
}
}
在WEB-INF文件夹中添加weblogic部署描述符。生成项目并部署。在我的例子中,我的xml看起来像。
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>
真的
真的
真的
/应用程序的上下文根
我只需将此设置为SecurityConfig即可解决此问题
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/s/**");
}
我相信对于weblogic,您需要一些额外的配置。您的项目中是否有
WEB-INF
文件夹?@AtaurRahmanMunna是的,我有带js css、/views/和xml的/s/文件夹:dispatcher servlet、WEB、weblogic、jdbc、tiles