相关疑难解决方法(0)

在web.xml文件中映射WebSocketEndpoints

我正在尝试开发一个Java EE 7 Web应用程序,它使用websocket端点并将其部署在Jetty服务器上.

该应用程序具有以下结构:

Game/
  src/
    main/
      java/
        game/
          WebSocketEndpoint.java
      webapp/
        index.html
        scripts/
          variousjavascriptstuff.js
        WEB-INF/
          beans.xml
          web.xml
Run Code Online (Sandbox Code Playgroud)

在beans.xml文件中:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
   bean-discovery-mode="annotated">
Run Code Online (Sandbox Code Playgroud)

WebSocketEndpoint被正确注释并且可以与Netbeans/Glassfish4一起使用,但是,应用程序必须部署在Jetty服务器上.

所以,我的问题 - 如何将websocket端点映射到web.xml文件中的URL /游戏?我已经找到了一些映射servlet的例子,但我认为这不适用于服务器端点.

或者,有没有办法为Jetty编写web.xml文件,以便它自动发现ll带注释的类/方法(类似于上面的beans.xml)

java web-applications jetty java-ee java-ee-7

5
推荐指数
1
解决办法
7526
查看次数

标签 统计

java ×1

java-ee ×1

java-ee-7 ×1

jetty ×1

web-applications ×1