Package com.vaadin.spring.server
Class SpringVaadinServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.vaadin.server.VaadinServlet
com.vaadin.spring.server.SpringVaadinServlet
- All Implemented Interfaces:
com.vaadin.server.Constants,jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class SpringVaadinServlet
extends com.vaadin.server.VaadinServlet
Subclass of the standard
Vaadin
servlet that adds a SpringUIProvider to every new Vaadin session and
allows the use of a custom service URL on the bootstrap page.
If you need a custom Vaadin servlet, you can either extend this servlet
directly, or extend another subclass of VaadinServlet and just add
the UI provider.
This servlet also implements a hack to get around the behavior of Spring ServletForwardingController/ServletWrappingController. Those controllers return null as the pathInfo of requests forwarded to the Vaadin servlet, and use the mapping as the servlet path whereas with Vaadin the mapping typically corresponds to a UI, not a virtual servlet. Thus, there is an option to clear the servlet path in requests and compute pathInfo accordingly. This is used by Vaadin Spring Boot to make it easier to use Vaadin and Spring MVC applications together in the same global "namespace".
- Author:
- Petter Holmström (petter@vaadin.com), Josh Long (josh@joshlong.com)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.server.VaadinServlet
com.vaadin.server.VaadinServlet.RequestType -
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEADFields inherited from interface com.vaadin.server.Constants
ATMOSPHERE_MISSING_ERROR, CANNOT_ACQUIRE_CLASSLOADER_SEVERE, DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_UI_FOUND, INVALID_ATMOSPHERE_VERSION_WARNING, INVALID_SECURITY_KEY_MSG, MAX_BUFFER_SIZE, NOT_PRODUCTION_MODE_INFO, PARAMETER_VAADIN_RESOURCES, PARAMETER_WIDGETSET, PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, PORTAL_PARAMETER_VAADIN_THEME, PORTAL_PARAMETER_VAADIN_WIDGETSET, PORTLET_CONTEXT, PUSH_NOT_SUPPORTED_ERROR, REQUIRED_ATMOSPHERE_RUNTIME_VERSION, SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_HEARTBEAT_INTERVAL, SERVLET_PARAMETER_LEGACY_DESIGN_PREFIX, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_PUSH_MODE, SERVLET_PARAMETER_PUSH_SUSPEND_TIMEOUT_LONGPOLLING, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, SERVLET_PARAMETER_SENDURLSASPARAMETERS, SERVLET_PARAMETER_SYNC_ID_CHECK, SERVLET_PARAMETER_UI_PRIORITY, SERVLET_PARAMETER_UI_PROVIDER, THEME_DIR_PATH, URL_PARAMETER_THEME, WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC, WARNING_PUSH_MODE_NOT_RECOGNIZED, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIR_PATH, WIDGETSET_MISMATCH_INFO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.server.VaadinServletServicecreateServletService(com.vaadin.server.DeploymentConfiguration deploymentConfiguration) protected com.vaadin.server.VaadinServletRequestcreateVaadinRequest(jakarta.servlet.http.HttpServletRequest request) Return the path of the service URL (URL for all client-server communication) relative to the context path.protected StringgetStaticFilePath(jakarta.servlet.http.HttpServletRequest request) Check if this is a request for a static resource and, if it is, return the resource path.protected voidvoidsetServiceUrlPath(String serviceUrlPath) Set the path of the service URL (URL for all client-server communication) to use, relative to the context path.Methods inherited from class com.vaadin.server.VaadinServlet
allowServePrecompressedResource, createDeploymentConfiguration, createDeploymentConfiguration, createServletService, criticalNotification, destroy, findResourceURL, getApplicationUrl, getCacheTime, getCurrent, getDefaultTheme, getLastPathParameter, getRequestType, getResourcePath, getService, handleContextRootWithoutSlash, init, isAllowedVAADINResourceUrl, isStaticResourceRequest, safeEscapeForHtml, serveStaticResources, serveStaticResourcesInVAADIN, service, stripSpecialChars, writeStaticResourceResponseMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
SpringVaadinServlet
public SpringVaadinServlet()
-
-
Method Details
-
servletInitialized
protected void servletInitialized() throws jakarta.servlet.ServletException- Overrides:
servletInitializedin classcom.vaadin.server.VaadinServlet- Throws:
jakarta.servlet.ServletException
-
getServiceUrlPath
Return the path of the service URL (URL for all client-server communication) relative to the context path. A value of null means that the default service path of Vaadin should be used. The path should start with a slash.- Returns:
- service URL path relative to context path (starting with slash) or null to use the default
-
setServiceUrlPath
Set the path of the service URL (URL for all client-server communication) to use, relative to the context path. The value null means that the default service URL of Vaadin should be used. The service URL path must be set before servlet service instances are created, i.e. before the servlet is placed into service by the servlet container.- Parameters:
serviceUrlPath- service URL path relative to the context path (starting with a slash) or null for default
-
createServletService
protected com.vaadin.server.VaadinServletService createServletService(com.vaadin.server.DeploymentConfiguration deploymentConfiguration) throws com.vaadin.server.ServiceException - Overrides:
createServletServicein classcom.vaadin.server.VaadinServlet- Throws:
com.vaadin.server.ServiceException
-
createVaadinRequest
protected com.vaadin.server.VaadinServletRequest createVaadinRequest(jakarta.servlet.http.HttpServletRequest request) - Overrides:
createVaadinRequestin classcom.vaadin.server.VaadinServlet
-
getStaticFilePath
Check if this is a request for a static resource and, if it is, return the resource path.- Overrides:
getStaticFilePathin classcom.vaadin.server.VaadinServlet- Parameters:
request- http client request- Returns:
- static file path or null if the request is not for a static resource.
-