我是Java EE的新手,我正在尝试使用.war文件http://community.jboss.org/wiki/ThreadDumpJSP,但似乎index.jsp文件没有显示变量,我只看到${thr.name} ${thr.state} ${thr.priority} ${thr.daemon}我在jboss和编辑:这是代码:package org.jboss.varia.threaddump.ThreadDumpBean;import java.io.Serializable;import java.util.*;public class ThreadDumpBean implements Serializable { private final Map traces; public ThreadDumpBean() {traces = new TreeMap(THREAD_COMP);traces.putAll(Thread.getAllStackTraces());} public Collection getThreads() {return traces.keySet();} public Map getTraces() {return traces;} /*** Compare the threads by name and id.*/ private static final Comparator THREAD_COMP = new Comparator() { public int compare(Thread o1, Thread o2) { int result = o1.getName().compareTo(o2.getName()); if (result == 0) { Long id1 = o1.getId(); Long id2 = o2.getId(); return id1.compareTo(id2); } return result; }};}和tomcat 6:<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %><jsp:useBean id="threadDump" class="org.jboss.varia.threaddump.ThreadDumpBean" scope="request"/><html><body><h2>Thread Summary</h2><table cellpadding="5" cellspacing="5"> <tr> <th>Thread</th> <th>State</th> <th>Priority</th> <th>Daemon</th> </tr> <c:forEach items="${threadDump.threads}" var="thr"> <tr> <td><c:out value='<a href="#${thr.id}">${thr.name}</a>' escapeXml="false"/></td> <td><c:out value="${thr.state}"/></td> <td><c:out value="${thr.priority}"/></td> <td><c:out value="${thr.daemon}"/></td> </tr> </c:forEach></table><h2>Thread Stack Traces</h2><c:forEach items="${threadDump.stackTraces}" var="trace"> <h4><c:out value='<a name="${trace.key.id}">${trace.key}</a>' escapeXml="false"/></h4> <pre> <c:forEach items="${trace.value}" var="traceline"> at <c:out value="${traceline}"/></c:forEach> </pre></c:forEach></body></html> (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 如果在Tomcat 6上部署JSP页面,则需要启用表达式语言才能使用它(出于向后兼容性的原因,默认情况下将其禁用)。这可以通过创建一个web.xml文件(其中Servlet规范的版本至少设置为2.4)来完成。您的web.xml文件应如下所示:<web-app id="TreadDumpApp" version="2.4"xmlns="http://java.sun.com/xml/ns/j2ee";xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";></web-app>要在JSP标记属性之外使用EL,您需要向web.xml添加更多事件魔术<web-app {...magic from above...}><jsp-property-group><url-pattern>/*</url-pattern><el-ignore>false</el-ignore></jsp-property-group></web-app>您还应该能够强制此页面允许使用EL,但是可以在页面顶部添加以下声明:<%@ page isELIgnored ="false" %>是的,这种双重否定非常优雅,是吗? ;-) (adsbygoogle = window.adsbygoogle || []).push({});
10-08 15:41