2012-03-03 25 views
0

我正在使用spring security將安全性集成到我的MVC應用程序中。我的web.xml片段是波紋管:web.xml中jsp配置中的多個taglib文件?

... 
<jsp-config> 
    <taglib> 
     <taglib-uri>/spring</taglib-uri> 
     <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location> 
    </taglib> 
    </jsp-config> 

</web-app> 

正如我讀/春季安全參考搜索,我發現this page在頁面的結束,相關的taglib。現在在我現有的MVC應用程序中,我已經有了.tld文件,如上面的片段所示。我應該爲security添加另一個.tld文件,例如security.tld並在web.xml中定義它?我應該如何使用?就像這樣:

<taglib-location> 
      /WEB-INF/tld/spring-form.tld 
      /WEB-INF/tld/security.tld 
</taglib-location> 

或者這樣:

 <taglib> 
      <taglib-uri>/spring</taglib-uri> 
      <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location> 
     </taglib> 
     <taglib> 
      <taglib-uri>/security</taglib-uri> 
      <taglib-location>/WEB-INF/tld/security.tld</taglib-location> 
     </taglib> 

請幫助。謝謝

* 編輯:*我使用彈簧2.5.6和2.0.4的安全

回答

2

一個選擇是聲明移動到一個共同的JSP(如果你使用的JSP),像這樣:

<%@ taglib uri="/WEB-INF/tld/spring-form.tld" prefix="spring" %> 
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="security" %> 

然後可以引用JSP任何你想使用這些標籤之一,如下圖(如果你使用瓷磚或SiteMesh的例如行之有效的模板)

<%@ include file="/jsp/common/taglibs.jsp" %> 
+0

非常感謝。它幫助我..從那時起我一直在尋找這個.. – AbdulAziz 2012-03-06 16:23:15

+0

我很高興它幫助。 – 2012-03-06 16:49:52