未配置嵌入式jetty webserver JSP支持 [英] Embedded jetty webserver JSP support not configured

查看:99
本文介绍了未配置嵌入式jetty webserver JSP支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前将Jetty嵌入到应用程序中。 Jetty服务器启动,我可以看到项目中的文件,但是当我尝试查看JSP文件时,它说

I currently have Jetty embedded into an application. The Jetty server starts up and I can see the files in the project, however when I try to view a JSP file it says


HTTP错误500
访问/web/index.jsp时遇到问题。原因:

未支持JSP支持

HTTP ERROR 500
Problem accessing /web/index.jsp. Reason:
JSP support not configured

我在这里阅读了一些其他帖子,在线阅读了一些教程他们谈论start.jar和maven。我没有使用其中任何一种我只是使用内置于eclipse中的内容。

I have read some other posts on here and some tutorials online and most of them talk about start.jar and maven. I'm not using either of those I'm just using what is built into eclipse.

我有三个类

AppContextBuilder

public class AppContextBuilder
{

private WebAppContext webAppContext;


public WebAppContext buildWebAppContext()
{
    webAppContext = new WebAppContext();
    webAppContext.setDescriptor( webAppContext + "/WEB-INF/web.xml" );
    webAppContext.setResourceBase( "." );
    webAppContext.setContextPath( "/" );
    return webAppContext;
}

JettyServer

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;

public class JettyServer
{

private Server server;


public JettyServer()
{
    this( 8585 );
}


public JettyServer(Integer runningPort)
{
    server = new Server( runningPort );
}


public void setHandler( ContextHandlerCollection contexts )
{
    server.setHandler( contexts );
}


public void start() throws Exception
{
    server.start();
}


public void stop() throws Exception
{
    server.stop();
    server.join();
}


public boolean isStarted()
{
    return server.isStarted();
}


public boolean isStopped()
{
    return server.isStopped();
}
}

ServerControl

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;

public class ServerControl
{

public static void main( String[] args )
{
    Logger.getLogger().logMethodEntryMessage();

    ContextHandlerCollection contexts = new ContextHandlerCollection();

    contexts.setHandlers( new Handler[]
    { new AppContextBuilder().buildWebAppContext() } );

    final JettyServer jettyServer = new JettyServer();
    jettyServer.setHandler( contexts );

    start( jettyServer );

    Logger.getLogger().logMethodExitMessage();        
}


private static void start( final JettyServer jettyServer )
{
    Logger.getLogger().logMethodEntryMessage();

    try
    {
        jettyServer.start();
        Logger.getLogger().debug( "Jetty server started!" );
    }
    catch( Exception e )
    {
        Logger.getLogger().error( e.getMessage() );
    }

    Logger.getLogger().logMethodExitMessage();
}

}

我从未尝试过使用过之前嵌入码头所以我可能会遗漏一些东西。我在线跟踪了这个教程,它似乎适合他们。

I've never tried to use jetty embedded before so I may be missing something. I followed this tutorial online though and it seems to work for them.

任何帮助都会很棒,谢谢!

Any help would be great, thanks!

推荐答案

管理来解决这个问题。

我所要做的就是创建一个WAR,然后将以下代码行添加到WebBuilderContext类中。

All I had to do was create a WAR and then add the following lines of code to the WebBuilderContext class.

webAppContext.setExtractWAR( true );    
webAppContext.setWar( "path/to/your/war/file/here" );

我正在为我的构建使用ANT,所以只添加了一个新的WAR目标来生成每个WAR文件我建立的时间。

I'm using ANT for my builds so just added a new WAR target to generate the WAR file each time I build.

希望这有助于其他人。

这篇关于未配置嵌入式jetty webserver JSP支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆