如何从Vaadin 14应用程序中访问`ServletContext`? [英] How to access `ServletContext` from within a Vaadin 14 app?

查看:129
本文介绍了如何从Vaadin 14应用程序中访问`ServletContext`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问的是与问题相同的问题, 如何从Vaadin 7应用程序中访问ServletContext? ,但针对Vaadin 14.

I am asking the same as the Question, How to access ServletContext from within a Vaadin 7 app?, but for Vaadin 14.

在Vaadin 7中,Vaadin提供了简单方便的呼叫:

In Vaadin 7, Vaadin provided the simple and handy call:

ServletContext servletContext = VaadinServlet.getCurrent().getServletContext();

该特定调用不再存在于 VaadinServlet 在Vaadin 14中.

That particular call is no longer there on VaadinServlet in Vaadin 14.

➥Vaadin API中的其他地方是否有等效项?

➥ Is there an equivalent somewhere else in the Vaadin API?

我的最终目标是使用键值属性"集合来保留对我的应用范围内对象的引用.

My end goal is to use the key-value "attribute" collection to keep references to my app-wide objects.

推荐答案

方法仍然存在,但未记录

两种方法:

Methods still there, but not documented

Both methods:

...在Vaadin 14中仍然存在.

…are there still in Vaadin 14.

似乎第二个方法VaadinServlet::getServletContext()未在Javadocs中列出,因为它是从

It seems the second method, VaadinServlet::getServletContext(), isn't listed in the Javadocs because it's inherited from javax.servlet.GenericServlet and the Javadoc generation is run in a way that doesn't have access to that class.

这篇关于如何从Vaadin 14应用程序中访问`ServletContext`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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