溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Struts2中用struts menu須注意哪些點(diǎn)

發(fā)布時(shí)間:2022-01-11 09:46:11 來(lái)源:億速云 閱讀:135 作者:柒染 欄目:編程語(yǔ)言

小編今天帶大家了解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文件中加入如下代碼:

參數(shù)是:menuConfig 對(duì)應(yīng)值是:菜單配置文件path!

Struts2.0 中的struts menu

menu-config.xml文件中

注意添加條目時(shí),一定要修改Item name屬性,不能重復(fù)哦,否則無(wú)法正常顯示!

Struts3.0中的struts menu

struts2中配置struts-menu

以前在struts1.x中需要在struts-config.xml中配置來(lái)引入struts-menu,現(xiàn)在在只需要在web.xml中配置一個(gè)監(jiān)聽就可以了



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)站的支持!

向AI問(wèn)一下細(xì)節(jié)

免責(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)容。

AI