zoukankan      html  css  js  c++  java
  • struts2官方 中文教程 系列九:Debugging Struts

    介绍

    在Struts 2 web应用程序的开发过程中,您可能希望查看由Struts 2框架管理的信息。本教程将介绍两种工具,您可以使用它们来查看。一个工具是Struts 2的配置插件,另一个是调试拦截器。本文还讨论了如何设置日志级别以查看更多或更少的日志消息。

    贴个本帖的地址,以免被爬:struts2官方 中文教程 系列九:Debugging Struts 即 http://www.cnblogs.com/linghaoxinpian/p/6916619.html 

    下载本章节代码

    Configuration Plugin(配置插件)

    Struts 2配置浏览器插件提供了关于运行程序的配置的详细信息。使用这个插件我们需要引入  struts2-config-browser-plugin-x.x.x.x.jar

    在第一章的时候,我们用的是min包,这次我们下载解压完整的包

     在index.jsp中添加如下内容

    <!--浏览器插件-->
    <hr>
    <a href='<s:url action="index" namespace="config-browser" />'>Launch the configuration browser</a>

    运行如下

     您可以单击链接来查看该操作的配置。例如,单击register动作链接会

     在页面的左侧是配置浏览器插件菜单。点击constants将呈现一个视图,列出所有的 Struts 2 常数和它们设置您的应用程序的属性的值。点击Jar显示应用程序正在使用的jar。

    使用拦截器(Debugging Interceptor)

    If you have set devMode to true (in the example application see struts.xml) then one of the interceptors that is activated when Struts 2 processes an action is the DebuggingInterceptor. 

    如果您已经将devMode设置为true(在Struts.xml文件中),然后当Struts 2处理一个action时,拦截器将被激活,这就是调试拦截器(DebuggingInterceptor)。拦截器将查找附加到URL上的查询字符串,该字符串具有调试的名称和xml、控制台、命令或浏览器。

    如果调试器发现了这个查询字符串,那么它将停止执行该操作,并返回到浏览器调试信息。返回信息的格式取决于拦截器找到的查询参数的值。更多的细节请参见DebuggingInterceptor

    我们修改上面代码

    index.jsp

    <!--浏览器插件-->
    <hr>
    <a href='<s:url action="index" namespace="config-browser" />'>Launch the configuration browser</a>

    修改为:

        <!--浏览器插件-->
        <hr>
        <a href='<s:url action="index" namespace="">
                    <s:param name="debug">browser</s:param>
                 </s:url>
                '>Launch the configuration browser</a>

    这是带参数的url标签,忘记的回去复习,运行如下

    在index.jsp中有一个链接显示debugging 信息。该链接包括查询字符串debug=browser。如果单击此链接,您将看到一个可以展开并折叠的列的表。这个表包含了各种对象和由Struts 2框架管理的状态。

    Note that to enable the correct display and interaction of the expand/collapse links on the debugging information web page you need to include the s:head tag in your JSP’s head section (see index.jsp in the example application) and also include the Struts 2 dojo plugin in your application’s class path. The Struts 2 dojo plugin is available as part of the Struts 2 download and from the Maven repository.

    不是很懂什么意思。dojo在包里并没有找到

    总结

    使用配置浏览器插件和调试拦截器可以帮助您解决Struts 2 web应用程序的问题。这些工具只应该用于开发。在创建用于部署到生产的war文件之前,您应该将devmode更改为false,并删除调试链接。您可能还希望将日志属性文件中的日志记录级别调整到一个更高的级别(信息或警告),以减少日志消息的数量。

  • 相关阅读:
    锚点
    DOM
    background
    Vue前端路由
    JavaScript常用方法
    算法——dfs介绍
    时间复杂度和空间复杂度
    CSS定位(position)
    CSS三栏布局
    前端笔试高频知识点汇总
  • 原文地址:https://www.cnblogs.com/linghaoxinpian/p/6916619.html
Copyright © 2011-2022 走看看