我是Spring框架的新手。在我的項目中,我使用Spring框架和瓷磚2(菜單,標題,正文和頁腳)。我想創建動態菜單並將其加載到菜單圖塊(爲菜單圖塊創建控制器)。我怎樣才能做到這一點?如果我跳過一些帖子,請告訴我。Springframework + Tiles
2
A
回答
0
你試過的是某種基於組件的東西(比如JSF),但是這對Spring MVC不起作用,因爲Spring MVC是一個基於命令的Web框架。
最後你的問題是,你需要添加由你的菜單控制器在任何其他控制器創建的所有模型中生成的模型。 我看到兩種方式來做到這一點。 的postHandle
- 手:在每一個正常的控制器的方法,您可以通過手工添加該機型爲菜單
- 隨着HandlerInterceptor:一個
org.springframework.web.servlet.HandlerInterceptor
是一種過濾器是被調用(被調用每個控制器方法之前,在控制器方法回退之後並且在jsp「被調用」之前,在jsp「返回」之後)。所以你重寫你的菜單控制器到一個HandlerInterceptor使用postHandle
方法(控制器和jsp之間的那個),並在那裏爲你的菜單添加模型。
@see
相關問題
- 1. java.lang.NoClassDefFoundError:org/springframework/context/EnvironmentAware
- 2. Springframework beans
- 3. Springframework PropertyPlaceholderConfigurer
- 4. Clickable Tiles
- 5. SpringFramework JdbcTemplate RowMapper
- 6. SLF4J as SpringFramework Logger
- 7. JCaptcha和SpringFramework
- 8. SessionAttribute和SpringFramework
- 9. java.lang.NoClassDefFoundError:org/springframework/core/DefaultParameterNameDiscoverer
- 10. Springframework 2.5.6和OSGi
- 11. org/springframework/core/AliasRegistry找不到
- 12. Apache Tiles 2.2.2將tiles-config.xml傳遞給JSP
- 13. 無法讀取TLD「META-INF/tld/tiles-jsp.tld」
- 14. Apache Tiles If/Else
- 15. Thymeleaf vs Tiles
- 16. SiteMesh或tiles
- 17. Velocity vs Apache Tiles
- 18. Struts Tiles ActionError
- 19. 使用Apache Tiles
- 20. DisplayTag和Tiles
- 21. SpriteKit Neighbouring Hex Tiles
- 22. Grails + Struts Tiles
- 23. drawing NSImage tiles
- 24. java.lang.NoClassDefFoundError:org/springframework/beans/factory/NoUniqueBeanDefinitionException
- 25. NoClassDefFoundError:org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor
- 26. NoClassDefFoundError:org/springframework/jdbc/core/RowMapper
- 27. java.lang.NoClassDefFoundError:org/springframework/transaction/interceptor/TransactionInterceptor
- 28. java.lang.NoClassDefFoundError:org/springframework/orm/hibernate5/HibernateTransactionManager
- 29. NoClassDefFoundError:org/springframework/context/support/ClassPathXmlApplicationContext
- 30. java.lang.NoClassDefFoundError:org/springframework/messaging/converter/MessageConverter
歡迎堆棧溢出!我們鼓勵你[研究你的問題](http://stackoverflow.com/questions/how-to-ask)。如果你已經[嘗試了某些東西](http://whathaveyoutried.com/),請將其添加到問題中 - 如果沒有,請先研究並嘗試您的問題,然後再回來。 – 2012-09-01 12:31:26
非常感謝您糾正我的錯誤 – drovka