2014-02-05 79 views
1

我想包括「春季安全3.2.0」到被無彈簧內置已有的Web應用程序和使用Primefaces & EJB 3春季安全3.2 - CSS顯示問題

當我開始與基本配置,並嘗試訪問沒有CSS樣式的頁面顯示。以下日誌包含有關路徑的一些信息。我不知道我錯過了什麼。

非常感謝提前。

應用程序日誌: -

  05-02-2014 16:05:58 INFO DispatcherServlet:472 - FrameworkServlet 'spring': initialization completed in 831 ms 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:141 - Servlet 'spring' configured successfully 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/css/myapp.css] 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/bg_myapp_header.gif] 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/js/myapp.js] 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/2_arial_white_myapp_bg.png] 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/logo.png] 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/css/myapp.css 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/js/myapp.js 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/js/myapp.js] 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/bg_myapp_header.gif 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/2_arial_white_myapp_bg.png 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/eba_logo.png 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/2_arial_white_myapp_bg.png] 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/bg_myapp_header.gif] 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/css/myapp.css] 
      05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/bg_myapp_header.gif] in DispatcherServlet with name 'spring' 
      05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/2_arial_white_myapp_bg.png] in DispatcherServlet with name 'spring' 
      05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/js/myapp.js] in DispatcherServlet with name 'spring' 
      05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/logo.png] 
      05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 
      05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 
      05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 
      05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/css/myapp.css] in DispatcherServlet with name 'spring' 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request 
      05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request 
      05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/logo.png] in DispatcherServlet with name 'spring' 

彈簧的security.xml

  <beans:beans xmlns="http://www.springframework.org/schema/security" 
       xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd 
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> 


       <authentication-manager> 
        <authentication-provider> 
         <user-service> 
          <user name="jay" password="jay" authorities="ROLE_USER" /> 
         </user-service> 
        </authentication-provider> 
       </authentication-manager> 

       <http pattern="/resources/css/**" security="none" /> 
       <http pattern="/resources/images/**" security="none" /> 
       <http pattern="/resources/js/**" security="none" /> 

       <http auto-config="true" use-expressions="true"> 

        <intercept-url pattern="/faces/javax.faces.resource/**" access="permitAll" /> 

        <intercept-url pattern="/faces/login.xhtml" access="permitAll" /> 
        <intercept-url pattern="/faces/search.xhtml" access="permitAll" /> 

        <intercept-url pattern="/faces/create.xhtml" access="hasRole('ROLE_USER')" /> 
        <intercept-url pattern="/faces/update.xhtml" access="hasRole('ROLE_USER')" /> 


        <intercept-url pattern="/**" access="permitAll" /> 
       </http> 
      </beans:beans> 

彈簧servlet.xml中

  <beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:context="http://www.springframework.org/schema/context" 
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation=" 
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.2.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> 

       <mvc:annotation-driven /> 

       <import resource="spring-security.xml" /> 

       <mvc:resources location="/css/**" mapping="/resources/css/" /> 
       <mvc:resources location="/images/**" mapping="/resources/images/" /> 
       <mvc:resources location="/js/**" mapping="/resources/js/" /> 

      </beans> 

web.xml中

  <?xml version="1.0" encoding="UTF-8"?> 
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
       id="WebApp_ID" version="3.0"> 


       <!-- JSF configuration --> 
       <servlet> 
        <servlet-name>Faces Servlet</servlet-name> 
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
        <load-on-startup>1</load-on-startup> 
       </servlet> 
       <servlet-mapping> 
        <servlet-name>Faces Servlet</servlet-name> 
        <url-pattern>/faces/*</url-pattern> 
       </servlet-mapping> 

       <!-- Filter for not to have local cache, instead load from server --> 
       <filter> 
        <filter-name>NoCacheFilter</filter-name> 
        <filter-class>com.jai.NoCacheFilter</filter-class> 
       </filter> 

       <filter-mapping> 
        <filter-name>NoCacheFilter</filter-name> 
        <url-pattern>/faces/*</url-pattern> 
       </filter-mapping> 

       <listener> 
        <listener-class>com.jai.HttpSessionChecker</listener-class> 
       </listener> 

       <!-- Primefaces theme --> 
       <context-param> 
        <param-name>primefaces.THEME</param-name> 
        <param-value>aristo</param-value> 
       </context-param> 


       <!-- Spring security configuration --> 
       <context-param> 
        <param-name>contextConfigLocation</param-name> 
        <param-value>/WEB-INF/spring-security.xml</param-value> 
       </context-param> 

       <filter> 
        <filter-name>springSecurityFilterChain</filter-name> 
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
       </filter> 

       <filter-mapping> 
        <filter-name>springSecurityFilterChain</filter-name> 
        <url-pattern>/*</url-pattern> 
       </filter-mapping> 

       <servlet> 
        <servlet-name>spring</servlet-name> 
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
       </servlet> 
       <servlet-mapping> 
        <servlet-name>spring</servlet-name> 
        <url-pattern>/</url-pattern> 
       </servlet-mapping> 

       <listener> 
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
       </listener> 

      </web-app> 

回答

1

如果刪除資源什麼路徑

<security:http pattern="/css/**" security="none"/> 
<security:http pattern="/images/**" security="none"/> 
<security:http pattern="/js/**" security="none"/> 
+0

感謝。但它仍然是相同的,即使我刪除/ resources/ – Jay

+0

@Jay添加Spring安全性工作之前呢? – jasilva

+0

是春季安全工作正常。 按預期給我提供用戶/密碼對話框。一旦我修復了CSS樣式問題,我會在安全性方面採取進一步措施。 – Jay

0

我有同樣的問題,在(地點去除**標記解決它=「/ CSS/**「),它爲我工作,定義一個文件夾來保存您的資源與Web內容文件夾。

<mvc:resources mapping="/resources/**" location="/assets/"/>` 

文件夾結構 應用程序名稱 - >的WebContent - >資產 - > CSS

JSP CSS URL

<link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/bootstrapStyles.css"/>"></link> 
<script src="<c:url value="/resources/js/jquery-1.12.0.js" />"></script>