您好,登錄后才能下訂單哦!
小編今天帶大家了解Struts2中用struts menu須注意哪些點(diǎn),文中知識(shí)點(diǎn)介紹的非常詳細(xì)。覺(jué)得有幫助的朋友可以跟著小編一起瀏覽文章的內(nèi)容,希望能夠幫助更多想解決這個(gè)問(wèn)題的朋友找到問(wèn)題的答案,下面跟著小編一起深入學(xué)習(xí)“Struts2中用struts menu須注意哪些點(diǎn)”的知識(shí)吧。
Struts1.0中的struts menu
menu-config.xml為菜單配置文件!
在struts1.2的struts-config.xml文件中加入如下代碼:
Struts2.0 中的struts menu
menu-config.xml文件中
注意添加條目時(shí),一定要修改Item name屬性,不能重復(fù)哦,否則無(wú)法正常顯示!
Struts3.0中的struts menu
struts2中配置struts-menu
以前在struts1.x中需要在struts-config.xml中配置
net.sf.navigator.menu.MenuContextListener
----MenuContextListener.java部分源代碼:--------public class MenuContextListener implements ServletContextListener {
private static Log log = LogFactory.getLog(MenuContextListener.class);
private ServletContext ctx;
private String menuConfig = "/WEB-INF/menu-config.xml";
public void contextInitialized(ServletContextEvent sce) {
ctx = sce.getServletContext();if (log.isDebugEnabled()) {
log.debug("Starting struts-menu initialization");
}// check for menuConfigLocation context-param
String override =
sce.getServletContext().getInitParameter("menuConfigLocation");
if (override != null) {
if (log.isDebugEnabled()) {
log.debug("using menuConfigLocation: " + override);
}
this.menuConfig = override;
}MenuRepository repository = new MenuRepository();
repository.setLoadParam(menuConfig);
......
對(duì)比struts1中的插件加載方式,這個(gè)舒心多了,但是struts2中菜單配置文件一定是:menu-config.xml,
struts1中則可以自己命名!
感謝大家的閱讀,以上就是“Struts2中用struts menu須注意哪些點(diǎn)”的全部?jī)?nèi)容了,學(xué)會(huì)的朋友趕緊操作起來(lái)吧。相信億速云小編一定會(huì)給大家?guī)?lái)更優(yōu)質(zhì)的文章。謝謝大家對(duì)億速云網(wǎng)站的支持!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。