Struts-Menu 在 Struts 2.x 中的使用 - MenuContextListener 不起作用

发布于 2024-11-08 12:59:49 字数 3640 浏览 4 评论 0原文

我已经彻底搜索了这个主题,并打开了 log4j 的调试级别,但 MenuContextListener 根本无法启动。这是我拥有的信息:

我的 web.xml 文件

 <listener> 
    <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class> 
 </listener> 

 <context-param>   
    <param-name>menuConfigLocation</param-name>   
    <param-value>/WEB-INF/classes/menu-config.xml</param-value>   
 </context-param> 

我的 menu-config.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>

<MenuConfig>

<Displayers>
   <Displayer name="TabbedMenu" type="net.sf.navigator.displayer.TabbedMenuDisplayer" />
</Displayers>

<Menus>
   <Menu name="selectAction" title="Select Action" location="SelectAction">
       <Item name="report" title="Report" location="Report"/>
       <Item name="query" title="Query" location="Query"/>
       <Item name="listings" title="Listings" location="Listings"/>
   </Menu>
</Menus>

</MenuConfig>

我的 log4j 信息

May 21, 2011 1:02:33 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myproject.war
context path = /myproject
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.TX
log4j:ERROR Could not instantiate appender named "TX".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
2011-05-21 13:02:52 MenuContextListener [DEBUG] Starting struts-menu initialization
2011-05-21 13:02:52 MenuContextListener [DEBUG] using menuConfigLocation: /WEBINF/classes/menu-config.xml
May 21, 2011 1:02:52 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 21, 2011 1:02:52 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/myproject] startup failed due to previous errors
2011-05-21 13:02:52 MenuContextListener [DEBUG] destroying struts-menu...
May 21, 2011 1:02:52 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
context path = /docs
May 21, 2011 1:02:52 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
context path = /examples
May 21, 2011 1:02:53 PM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 21, 2011 1:02:53 PM org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
May 21, 2011 1:02:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 35104 ms

所以你看到 contextInitialize 被为此监听器调用,但该方法没有完成,因为 MenuContextListener 中应该还有 1 个日志语句我们成功或失败。然后我们突然调用了 contextDestroyed ,就是这样。

I have thoroughly googled this topic and have turned on debug level for log4j, but the MenuContextListener simply will not start. Here is the info I have:

My web.xml file

 <listener> 
    <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class> 
 </listener> 

 <context-param>   
    <param-name>menuConfigLocation</param-name>   
    <param-value>/WEB-INF/classes/menu-config.xml</param-value>   
 </context-param> 

My menu-config.xml file

<?xml version="1.0" encoding="UTF-8" ?>

<MenuConfig>

<Displayers>
   <Displayer name="TabbedMenu" type="net.sf.navigator.displayer.TabbedMenuDisplayer" />
</Displayers>

<Menus>
   <Menu name="selectAction" title="Select Action" location="SelectAction">
       <Item name="report" title="Report" location="Report"/>
       <Item name="query" title="Query" location="Query"/>
       <Item name="listings" title="Listings" location="Listings"/>
   </Menu>
</Menus>

</MenuConfig>

My log4j info

May 21, 2011 1:02:33 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myproject.war
context path = /myproject
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.TX
log4j:ERROR Could not instantiate appender named "TX".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
2011-05-21 13:02:52 MenuContextListener [DEBUG] Starting struts-menu initialization
2011-05-21 13:02:52 MenuContextListener [DEBUG] using menuConfigLocation: /WEBINF/classes/menu-config.xml
May 21, 2011 1:02:52 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 21, 2011 1:02:52 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/myproject] startup failed due to previous errors
2011-05-21 13:02:52 MenuContextListener [DEBUG] destroying struts-menu...
May 21, 2011 1:02:52 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
context path = /docs
May 21, 2011 1:02:52 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
context path = /examples
May 21, 2011 1:02:53 PM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 21, 2011 1:02:53 PM org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
May 21, 2011 1:02:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 35104 ms

So you see the contextInitialize is called for this listener, but the method does not complete because there should be 1 more log statement within MenuContextListener telling us success or failure. Then we suddenly get contextDestroyed called and that is that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁人与我共长歌 2024-11-15 12:59:49

因此,绝对没有任何日志可以为我提供更多信息。无处!为了找到问题,我不得不费尽心思地梳理struts-main的源代码。我发现了什么?在 MenuRepository.java 中导入了 commons-digester。公共消化器?在任何文档中哪里提到了这一点或在任何下载中包含了这一点?我不使用公共消化器。

这是我对此的看法,如果我错了,请任何人纠正我,如果这是正确的,请确认。回到 struts 1.x 编写本文时,commons-digester 是 struts 包的一部分,那么为什么要在 struts-menu 文档中提及 commons-digester 呢?现在情况已不再如此,因此必须单独下载 commons-digester。所以我的结论是,需要在某个地方有文档来说明这个包如何成功地与 struts 2.x 结合。

另外,谁能给我任何 2011 年使用 struts-menu 的替代方案?我有一个菜单,当用户将鼠标悬停在其上时,该菜单会在右侧打开。这与 struts-menu 中包含的 Velocity CoolWindows 示例非常相似。

So there was absolutely no log present anywhere that gave me any more information. Nowhere! What I did to find the problem was that I had to painstakingly comb through the source code for struts-main. And what did I find? In MenuRepository.java there was an import of commons-digester. Commons-digester? Where is this mentioned in any documentation or included in any download? I don't use commons digester.

Here is my take on this, anyone please correct me if I am wrong or affirm if this is somehow right. Back in struts 1.x when this was written, commons-digester was part of the struts package so why mention commons-digester in the struts-menu documentation? That is now no longer the case, so one has to separately download commons-digester. So my conclusion is that there needs to be documentation somewhere as how this package can be successfully combined with struts 2.x.

Also, can anyone give me any 2011 alternatives to using struts-menu? I have a menu which opens up to the right when the user hovers over it. This is pretty similar to the Velocity CoolWindows example included with struts-menu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文