我正在使用vaadin6,所以我使用以下方法来检索Web应用程序参数:
public abstract class Application implements URIHandler,
Terminal.ErrorListener, Serializable {
/**
* Searches for the property with the specified name in this application.
* This method returns <code>null</code> if the property is not found.
*
* See {@link #start(URL, Properties, ApplicationContext)} how properties
* are defined.
*
* @param name
* the name of the property.
* @return the value in this property list with the specified key value.
*/
public String getProperty(String name) {
return properties.getProperty(name);
}
//...
}
迁移到vaadin7后,我想使用相同的功能,但我找不到它。
答案 0 :(得分:7)
看来你正在寻找
VaadinServlet.getCurrent().getServletContext().getInitParameter("name");
它授予对web.xml中定义的参数的访问权限,例如:
<context-param>
<param-name>name</param-name>
<param-value>John</param-value>
</context-param>