2013-11-04 100 views
0

我的問題是類似這樣的:春季安全,SiteMesh的與標籤庫

Spring security tags in sitemesh decorator

我使用的sitemesh在春季安全Spring MVC的項目。我的web.xml看起來是這樣的:

<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> 

<filter> 
    <filter-name>sitemesh</filter-name> 
    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> 
</filter> 

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

而且我NavBar.jsp(我使用了Spring MVC引導櫥窗),它包含在由裝飾的sitemesh每一頁,看起來是這樣的:

<div class="navbar-collapse collapse"> 
     <ul class="nav navbar-nav"> 

     <security:authorize ifAnyGranted="ROLE_UPDATE"> 
      <li ><a href="<c:url value="/dataupdate" />">Update</a></li> 
     </security:authorize> 

     <security:authorize ifAnyGranted="ROLE_ADMIN"> 
      <li ><a href="<c:url value="/settings" />">Settings</a></li> 
     </security:authorize> 

     <li><a href="j_spring_security_logout">Logout</a></li>       
     </ul> 
    </div> 

所有工作都按預期進行(即僅當經過身份驗證的用戶具有正確角色時纔會顯示導航欄項目),但默認的Spring Security登錄頁面未進行裝飾。我可以通過在Spring Security過濾器上面的web.xml中移動Sitemesh過濾器來解決這個問題,然而NavBar.jsp中的安全標籤停止工作。

我有兩種方法嗎?

回答

1

爲了解決這個問題,我實現了一個自定義的login.jsp頁面,並且sitemesh剛剛啓動了它。

0

pelase更改過濾器的順序並嘗試..它應該工作