com.vaadin.flow.spring.
Class SpringServlet
All Implemented Interfaces:
jakarta.servlet.Servlet
, jakarta.servlet.ServletConfig
, Serializable
Direct Known Subclasses:
Spring application context aware Vaadin servlet implementation.
This class is not intended to be used directly. It's instantiated automatically by the Spring add-on:
- Spring boot does this via
SpringBootAutoConfiguration
. - In case of using Spring MVC just extends
VaadinMVCWebAppInitializer
.
Author:
Vaadin Ltd
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionProperty names that are read from the application.properties file
Fields inherited from class com.vaadin.flow.server.VaadinServlet
INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATH
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
ConstructorsConstructorDescriptionSpringServlet
(org.springframework.context.ApplicationContext context, boolean rootMapping) Creates a new Vaadin servlet instance with the application
context
provided. -
Method Summary
Modifier and TypeMethodDescriptionprotected DeploymentConfiguration
createDeploymentConfiguration
(Properties initParameters) Creates a deployment configuration to be used for the creation of a
VaadinService
.protected VaadinServletService
createServletService
(DeploymentConfiguration deploymentConfiguration) Creates a vaadin servlet service.
protected void
service
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Receives standard HTTP requests from the public service method and dispatches them.
Methods inherited from class com.vaadin.flow.server.VaadinServlet
createDeploymentConfiguration, createServletService, createStaticFileHandler, createVaadinRequest, destroy, getCurrent, getFrontendMapping, getLastPathParameter, getService, getServletConfig, handleContextOrServletRootWithoutSlash, init, serveStaticOrWebJarRequest, servletInitialized, whenFrontendMappingAvailable
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
PROPERTY_NAMES
Property names that are read from the application.properties file
-
-
Constructor Details
-
SpringServlet
public SpringServlet(org.springframework.context.ApplicationContext context, boolean rootMapping) Creates a new Vaadin servlet instance with the application
context
provided.Use
true
as a value forforwardingEnforced
parameter if your servlet is mapped to the root ("/*"
). In the case of root mapping aRootMappedCondition
is checked andVaadinServletConfiguration
is applied conditionally. This configuration provide aServletForwardingController
so that other Spring endpoints may co-exist with Vaadin application (it's required since root mapping handles any request to the context). This is not needed if you are using non-root mapping since are you free to use the mapping which doesn't overlap with any endpoint mapping. In this case usefalse
for theforwardingEnforced
parameter.Parameters:
context
- the Spring application contextrootMapping
- the incoming HttpServletRequest is wrapped in ForwardingRequestWrapper iftrue
-
-
Method Details
-
service
protected void service(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException Description copied from class:
VaadinServlet
Receives standard HTTP requests from the public service method and dispatches them.
Overrides:
service
in classVaadinServlet
Parameters:
request
- the object that contains the request the client made of the servlet.response
- the object that contains the response the servlet returns to the client.Throws:
jakarta.servlet.ServletException
- if an input or output error occurs while the servlet is handling the TRACE request.IOException
- if the request for the TRACE cannot be handled. -
createServletService
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException Description copied from class:
VaadinServlet
Creates a vaadin servlet service.
Overrides:
createServletService
in classVaadinServlet
Parameters:
deploymentConfiguration
- the deployment configuration to be usedReturns:
the created vaadin servlet service
Throws:
ServiceException
- if creating the vaadin servlet service fails -
createDeploymentConfiguration
Description copied from class:
VaadinServlet
Creates a deployment configuration to be used for the creation of a
VaadinService
. Override this if you want to override certain properties.Overrides:
createDeploymentConfiguration
in classVaadinServlet
Parameters:
initParameters
- the context-param and init-param values as propertiesReturns:
the created deployment configuration
-