Jersey JAX-RS REST API application与此处描述的非常相似,它运行在 Grizzly 容器之上。需要映射/托管 src\main\webapp
文件夹的内容,该文件夹具有使用 REST API 的 AngularJS 应用程序。
目前,REST API 在 Grizzly 的帮助下在 Main
中启动:
GrizzlyHttpServerFactory.createHttpServer(....);
在同一台服务器上运行 REST API 和前端有哪些选项? 如何设置?
最佳答案
GrizzlyHttpServerFactory.createHttpServer(....);
返回 HttpServer
的实例,它只是一个预配置了网络监听器和 Jersey http 处理程序的通用服务器。
因此,它仅处理 REST 请求(通过 Jersey http 处理程序),但您可以添加自己的 http 处理程序来处理您的 Web 应用程序(html、js、css...):
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(....);
server.getServerConfiguration().addHttpHandler(....) // add your handler here and map it to URL
看看 Jersey source code了解更多详情。
关于java - 在与 JAX-RS REST API 相同的服务器上公开 AngularJS 前端有哪些选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36321605/