Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Django调试工具栏模板列出Struts2的功能_Java_Debugging_Servlets_Struts2_Sitemesh - Fatal编程技术网

Java Django调试工具栏模板列出Struts2的功能

Java Django调试工具栏模板列出Struts2的功能,java,debugging,servlets,struts2,sitemesh,Java,Debugging,Servlets,Struts2,Sitemesh,我正在开发一个用作模板引擎的应用程序。我需要的是请求使用的所有JSP模板的列表 在我使用的其他项目中,除了许多其他有用的信息外,它还为我提供了用于显示页面的请求模板列表 当我有600多个模板组成一个复杂的模板网络,并且我需要将其中一个模板中的a更改为a时,这个列表非常有用 我并不期望Struts2有这么好的结果,只是一个LOG.debug的原始列表;将使我的工作变得更加轻松。好的,我读了一些,并上了以下课程: package x; import java.util.Map; import o

我正在开发一个用作模板引擎的应用程序。我需要的是请求使用的所有JSP模板的列表

在我使用的其他项目中,除了许多其他有用的信息外,它还为我提供了用于显示页面的请求模板列表

当我有600多个模板组成一个复杂的模板网络,并且我需要将其中一个模板中的a更改为a时,这个列表非常有用

我并不期望Struts2有这么好的结果,只是一个LOG.debug的原始列表;将使我的工作变得更加轻松。

好的,我读了一些,并上了以下课程:

package x;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;

public class TemplatesDebugInterceptor extends AbstractInterceptor {

    private static final long serialVersionUID = 4030044344066761593L;
    Log log = LogFactory.getLog(TemplatesDebugInterceptor.class);

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        try {
            if (ServletActionContext.getActionMapping() != null) {
                String className = invocation.getAction().getClass().getCanonicalName();
                String methodName = ServletActionContext.getActionMapping().getMethod();
                log.info("===========================");
                log.info(className+"."+methodName);
            }
            invocation.addPreResultListener(new PreResultListener() {
                public void beforeResult(ActionInvocation invocation,String resultCode) {
                    Map<String, ResultConfig> resultsMap = invocation.getProxy().getConfig().getResults();
                    ResultConfig finalResultConfig = resultsMap.get(resultCode);
                    log.info(finalResultConfig.getParams());
                }
            });
        } catch (Exception e) {
            log.error("[ERROR] Could not list templates: ", e);
        }
        return invocation.invoke();
    }
}
如果我发现一些额外有用的输出,我会更新这篇文章

<interceptors>
    <interceptor name="templates" class="x.TemplatesDebugInterceptor" />
    (...)
    <interceptor-stack name="defaultStackBizgov">
        <interceptor-ref name="templates"/>
        (...)
13:52:00,279 INFO  [STDOUT] [INFO] (http-0.0.0.0-8080-7) TemplatesDebugInterceptor - x.ProcedureDetailsAction.validateSubmitPublication
13:52:00,357 INFO  [STDOUT] [INFO] (http-0.0.0.0-8080-7) TemplatesDebugInterceptor - {location=/WEB-INF/jsp/indexPage.jsp}
13:52:00,763 INFO  [STDOUT] [INFO] (http-0.0.0.0-8080-7) TemplatesDebugInterceptor - {location=/WEB-INF/jsp/publicationView.jsp}