Package com.vaadin.flow.spring
Class SpringServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.vaadin.flow.server.VaadinServlet
com.vaadin.flow.spring.SpringServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
- Direct Known Subclasses:
MockSpringServlet
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 fileFields inherited from class com.vaadin.flow.server.VaadinServlet
INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATHFields 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 applicationcontextprovided. -
Method Summary
Modifier and TypeMethodDescriptionprotected DeploymentConfigurationcreateDeploymentConfiguration(Properties initParameters) Creates a deployment configuration to be used for the creation of aVaadinService.protected VaadinServletServicecreateServletService(DeploymentConfiguration deploymentConfiguration) Creates a vaadin servlet service.protected voidservice(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, whenFrontendMappingAvailableMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods 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 applicationcontextprovided.Use
trueas a value forforwardingEnforcedparameter if your servlet is mapped to the root ("/*"). In the case of root mapping aRootMappedConditionis checked andVaadinServletConfigurationis applied conditionally. This configuration provide aServletForwardingControllerso 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 usefalsefor theforwardingEnforcedparameter.- 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:VaadinServletReceives standard HTTP requests from the public service method and dispatches them.- Overrides:
servicein 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:VaadinServletCreates a vaadin servlet service.- Overrides:
createServletServicein classVaadinServlet- Parameters:
deploymentConfiguration- the deployment configuration to be used- Returns:
- the created vaadin servlet service
- Throws:
ServiceException- if creating the vaadin servlet service fails
-
createDeploymentConfiguration
Description copied from class:VaadinServletCreates a deployment configuration to be used for the creation of aVaadinService. Override this if you want to override certain properties.- Overrides:
createDeploymentConfigurationin classVaadinServlet- Parameters:
initParameters- the context-param and init-param values as properties- Returns:
- the created deployment configuration
-