使用jetty调试web应用,出现
JSP support not configured
的问题,原因是缺少依赖的jar
jsp-2.1-jetty
maven依赖如下:
<properties> <jetty.version>6.1.26</jetty.version> </properties> <dependencies> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty</artifactId> <version>${jetty.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-plus</artifactId> <version>${jetty.version}</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-naming</artifactId> <version>${jetty.version}</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jsp-2.1-jetty</artifactId> <version>${jetty.version}</version> <scope>test</scope> </dependency> </dependencies>
JAVA代码如下:
import org.mortbay.jetty.Connector; import org.mortbay.jetty.Server; import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.thread.QueuedThreadPool; public class Runner { private static Server server = new Server(); public static void main(String[] args) throws Exception { QueuedThreadPool boundedThreadPool = new QueuedThreadPool(); boundedThreadPool.setMaxThreads(100); server.setThreadPool(boundedThreadPool); Connector connector = new SelectChannelConnector(); connector.setPort(8080); server.addConnector(connector); WebAppContext context = new WebAppContext("src/main/webapp", "/"); context.setConfigurationClasses(new String[] { "org.mortbay.jetty.webapp.WebInfConfiguration", "org.mortbay.jetty.plus.webapp.EnvConfiguration", "org.mortbay.jetty.plus.webapp.Configuration", "org.mortbay.jetty.webapp.JettyWebXmlConfiguration", "org.mortbay.jetty.webapp.TagLibConfiguration" }); server.setHandler(context); server.setStopAtShutdown(true); server.setSendServerVersion(true); server.start(); server.join(); } }