嵌入式容器,易于使用和HTML

时间:2018-07-29 21:35:57

标签: java resteasy

我正在尝试启动Java SE构想:Undertow + RestEasy + Weld。 正常的JSON响应都成功,一切正常。

现在,我正在尝试提供一个简单的htm页面:

引导程序:

    UndertowJaxrsServer server = new UndertowJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplicationClass(RestEasyConfig.class.getName());
    deployment.setInjectorFactoryClass("org.jboss.resteasy.cdi.CdiInjectorFactory");

    DeploymentInfo deploymentInfo = server.undertowDeployment(deployment)
            .setClassLoader(GatewayApi.class.getClassLoader())
            .setContextPath("/")
            .addListener(Servlets.listener(Listener.class))
            .setDeploymentName("Undertow RestEasy Weld");
    server.deploy(deploymentInfo);
    Undertow.Builder undertowBuilder = Undertow.builder()
            .addHttpListener(getServerPort(properties), "0.0.0.0");
    server.start(undertowBuilder);

和终点:

    @Path("/hello")
    @Produces("text/html")
    public class HelloView {

        @GET
        public View hello() {
            System.out.println("Test");
            return new View("/index.htm");
        }
    }

我可以在类路径中看到htm文件,但是..无法正常工作。 视图类来自:import org.jboss.resteasy.plugins.providers.html.View; 没有引发异常...

有什么建议吗?

0 个答案:

没有答案