請看看我的安全-config.xml中的一部分:春季安全網址攔截:不同行爲的Tomcat 7和JBoss Wildfly 8
<http use-expressions="true">
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/home" access="permitAll" />
[other stuff here]
<intercept-url pattern="/**" access="denyAll" />
</http>
讓我們假設我的應用程序上下文名稱爲koko
。
這工作正常,在Tomcat中:當我訪問http://tomcat-url:8080/koko/
或http://tomcat-url:8080/koko/home
我看到一個主頁問我登錄 - 後,我登錄,我重定向到http://tomcat-url:8080/koko/
,我可以看到鏈接到其他的東西。
當我嘗試在JBoss中做同樣的事情時,我訪問http://jboss-url:8080/koko/
,我立即得到一個登錄頁面!如果我訪問http://jboss-url:8080/koko/home
,我會看到主頁要求我登錄。現在,我登錄後,我又被重定向到http://jboss-url:8080/koko/
,我得到了一個拒絕訪問!如果我在登錄後手動轉到http://jboss-url:8080/koko/home
,我會看到其他員工並能正常導航。
所以,問題似乎是JBoss的不理解行
<intercept-url pattern="/" access="permitAll" />
,或者是由下面的/**
線覆蓋。然而,tomcats可以和at正常工作。這不應該依賴於Application Server,因爲它完全與彈簧相關,並且兩個應用程序都使用相同的彈簧。
更新 - 解決方案:基於@ M.Deinum的回答,我添加了一個名爲/index.html的新url請求映射到我的主頁,並且一個允許所有行到該url - 並且工作正常!
我建議你打開日誌並看看會發生什麼。我的猜測是,在JBoss中'/'被重新映射爲'/ index.jsp'。 JBoss有自己的容器,可能會以不同的方式處理URI。 –
@ M.Deinum是的,你是對的 - JBoss出於我未知的原因試圖找到/koko/index.html當我去/ koko /。你可以添加一個正確的答案,以便我可以接受它嗎? – Serafeim