2017-10-12 123 views
0

我有Spring安全性的web應用程序。Spring Security weblogic js loading

當我在tomcat9上運行我的應用程序時,所有工作都正常,但是當我使用oracle Weblogic時,出現了一些問題,並且我的應用程序中的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

相信對於weblogic的,你需要一些額外的配置解決它。您的項目中是否有任何「WEB-INF」文件夾? –

+0

@AururRahmanMunna是的,我有我的/ s /文件夾與js css,/ views/ – Coder

+0

和xml:dispatcher-servlet,web,weblogic,jdbc,tiles – Coder

回答

0

我只是把到SecurityConfig這個

@Override 
public void configure(WebSecurity web) throws Exception { 
    web.ignoring().antMatchers("/s/**"); 
} 
0

添加WebLogic部署描述符WEB-INF folder.Build項目和部署。在我的情況下,我的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>